stronk7

Untitled

May 26th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. SELECT u.id, u.picture, u.firstname, targetusers.lastname,.....,
  2. COALESCE(ul.timeaccess, 0) AS lastaccess,
  3. ctx.id AS ctxid, ctx.path AS ctxpath, ....
  4. FROM
  5. (SELECT DISTINCT tu.id
  6. FROM b1user tu
  7. JOIN b1user_enrolments ue ON ue.userid = tu.id
  8. JOIN b1enrol e ON e.id = ue.enrolid AND e.courseid = :o_courseid1
  9. ) targetusers
  10. JOIN b1user u ON u.id = targetusers.id
  11. LEFT JOIN b1user_lastaccess ul ON (ul.userid = targetusers.id AND ul.courseid = :o_courseid2)
  12. LEFT JOIN b1context ctx ON (ctx.instanceid = targetusers.id AND ctx.contextlevel = :o_contextlevel)
  13. <<OTHER FILTERS GO HERE>>
  14. ORDER BY xxxxxxx ASC
Advertisement
Add Comment
Please, Sign In to add comment