Guest User

Untitled

a guest
Jul 18th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. SELECT DISTINCT T.category_id, T.id, T.tag, IF (ACT.tag_id IS NULL, 0, 1) AS status
  2. FROM exercise_tag ET2, tag T LEFT JOIN
  3. (
  4. SELECT ET.tag_id
  5. FROM exercise_tag ET,
  6. (
  7. SELECT E.exercise_id
  8. FROM exercise_tag E
  9. WHERE E.tag_id IN ('29','1')
  10. GROUP BY E.exercise_id
  11. HAVING count(E.exercise_id) = 2
  12. )
  13. EX WHERE ET.exercise_id=EX.exercise_id
  14. GROUP BY ET.tag_id
  15. )
  16. ACT ON (T.id=ACT.tag_id)
  17. LEFT JOIN tag_category TC ON (T.category_id=TC.id)
  18. WHERE
  19. ET2.tag_id=T.id
  20. ORDER BY T.category_id
Add Comment
Please, Sign In to add comment