Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. SELECT DISTINCT journey.id, line.name AS line, getDestination(pattern.section) AS destination, TIME_FORMAT(ADDTIME(journey.departure, SEC_TO_TIME(SUM(pl2.time))), '%H:%i') AS departure, operator.code AS operator, bus.registration
  2. FROM journey
  3. INNER JOIN journey_day ON journey_day.journey = journey.id
  4. INNER JOIN service ON service.id = journey.service
  5. INNER JOIN operator ON operator.id = service.operator
  6. INNER JOIN line ON line.service = service.id
  7. INNER JOIN pattern ON pattern.id = journey.pattern
  8. INNER JOIN pattern_link pl ON pl.section = pattern.section AND pl.from_stop = :stop
  9. INNER JOIN pattern_link pl2 ON pl2.section = pattern.section AND pl2.sequence < pl.sequence
  10. LEFT JOIN findmybus.bus ON bus.journey_id = journey.id
  11. WHERE journey_day.day = :day AND CURDATE() BETWEEN service.date_start and service.date_end AND operator.id = :operator
  12. GROUP BY journey.id, journey.departure
  13. HAVING (TIME_TO_SEC(journey.departure) + SUM(pl2.time)) < 86400
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement