Guest User

Untitled

a guest
Jul 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. SELECT min(t1.id) as refer, t1.parent_id, t1.user_id as us_id, t2.cnt
  2. FROM modxev_programm_one as t1
  3. LEFT JOIN
  4. (
  5. SELECT parent_id, COUNT(parent_id) as cnt
  6. FROM modxev_programm_one
  7. WHERE parent_id is not null
  8. GROUP BY parent_id
  9. ) as t2
  10. ON t1.id = t2.parent_id
  11. WHERE t2.cnt > 0 and t2.cnt < 2
Add Comment
Please, Sign In to add comment