Advertisement
Guest User

Untitled

a guest
Apr 7th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.47 KB | None | 0 0
  1. SELECT e.* FROM mdl_event e
  2. INNER JOIN (
  3.   SELECT ev.modulename, ev.instance, ev.eventtype, MIN(ev.priority) as priority FROM (
  4.     SELECT modulename, instance, eventtype, priority FROM mdl_event ev
  5.       WHERE (ev.userid = ? AND ev.courseid = ? AND ev.groupid = ? AND ev.categoryid = ?) UNION
  6.         SELECT modulename, instance, eventtype, priority FROM mdl_event ev
  7.           WHERE (ev.groupid != ? AND ev.eventtype = ?) UNION
  8.           SELECT modulename, instance, eventtype, priority FROM mdl_event ev
  9.             WHERE (ev.groupid = ? AND ev.courseid IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) AND ev.categoryid = ?) UNION
  10.             SELECT modulename, instance, eventtype, priority FROM mdl_event ev
  11.               WHERE (ev.categoryid != ? AND ev.eventtype = ?)) ev
  12.               GROUP BY ev.modulename, ev.instance, ev.eventtype
  13. ) fe ON e.modulename = fe.modulename AND e.instance = fe.instance AND e.eventtype = fe.eventtype AND (e.priority = fe.priority OR (e.priority IS NULL AND fe.priority IS NULL))
  14. LEFT JOIN mdl_modules m ON e.modulename = m.name
  15.   WHERE (m.visible = ? OR m.visible IS NULL) AND type = ? AND timesort >= ? AND timesort <= ? AND ((e.userid = ? AND e.courseid = ? AND e.groupid = ? AND e.categoryid = ?) OR e.groupid != ? OR (e.groupid = ? AND e.courseid IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)) OR (e.groupid = ? AND e.courseid = ? AND e.categoryid != ?)) AND (e.visible = ?)
  16.   ORDER BY COALESCE(e.timesort, e.timestart) ASC, e.id ASC LIMIT ?, ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement