Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select distinct u.id,
- SQRT(POW(69.1 * (l.Latitude - 49.8147253578057), 2) + POW(69.1 * (24.0197496861219 - l.Longitude) * COS(l.Latitude / 57.3), 2)) AS distance
- FROM user u
- join location l on
- (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) *
- cos((24.0197496861219 * 0.0175) - (l.Longitude * 0.0175))) * 3959 <= 25)
- join current_subject c on
- (c.id in (select id_current_subject from user_current_subject where id_user = u.id) and c.subject_id = 2
- and 3 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
- and 4 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
- and 7 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
- and 13 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
- and 15 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
- and 16 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
- and 17 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
- and 18 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
- and 25 in (select id_curriculum from current_subject_curriculum where c.id = id_current_subject)
- )
- where u.role = 1
- and u.status >= 103
- and u.status != 105
- and u.status != 106
- ORDER BY distance LIMIT 30 OFFSET 0
Add Comment
Please, Sign In to add comment