Guest User

Untitled

a guest
Jan 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. select distinct u.id,
  2. SQRT(POW(69.1 * (l.Latitude - 49.8147253578057), 2) + POW(69.1 * (24.0197496861219 - l.Longitude) * COS(l.Latitude / 57.3), 2)) AS distance
  3. FROM user u
  4. join location l on
  5. (l.id = u.location_id and acos(sin(l.Latitude * 0.0175) * sin(49.8147253578057 * 0.0175) + cos(l.Latitude * 0.0175) * cos(49.8147253578057 * 0.0175) *
  6. cos((24.0197496861219 * 0.0175) - (l.Longitude * 0.0175))) * 3959 <= 25)
  7. join current_subject c on
  8. (c.id in (select id_current_subject from user_current_subject where id_user = u.id) and c.subject_id = 2
  9. and 3 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
  10. and 4 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
  11. and 7 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
  12. and 13 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
  13. and 15 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
  14. and 16 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
  15. and 17 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
  16. and 18 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
  17. and 25 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
  18. )
  19. where u.role = 1
  20. and u.status >= 103
  21. and u.status != 105
  22. and u.status != 106
  23. ORDER BY distance LIMIT 30 OFFSET 0
Add Comment
Please, Sign In to add comment