Jump to content

Additions in SQL


051119

Recommended Posts

Hi all,

 

I've got 2 tables as below:

 

stops

Stop_name

RouteNumb

Order

Min_from_start

 

routes

RouteNumb

Start_time

 

In essence, Start_time contains the time the bus sets out on its journey, and Min_from_start is how many minutes from the first stop the bus is (eg. so if Start_time is 09:00 and Min_from_start is 14, then I'm looking for 09:14).

 

Can anyone please help me find an SQL query to calculate this?

 

So far I've got

SELECT stops.Stop_name, stops.Min_from_start, routes.Start_time
FROM routes INNER JOIN stops ON Routes.RouteNumb = stops.route
WHERE (((stops.route)="12"));

Which shows the info but not the times.

 

Thank you so much!

Link to comment
https://forums.phpfreaks.com/topic/186952-additions-in-sql/
Share on other sites

Assuming you store Start_time as TIME

 

SELECT stops.Stop_name, stops.Min_from_start, routes.Start_time, routes.Start_time + INTERVAL stops.Min_from_start MINUTE AS stopTime
FROM routes INNER JOIN stops ON Routes.RouteNumb = stops.route
WHERE (((stops.route)="12"));

 

 

Link to comment
https://forums.phpfreaks.com/topic/186952-additions-in-sql/#findComment-987241
Share on other sites

Thank you ever so much for your reply! :)

 

Access throws up this error though

  Quote
Syntax error (missing operator) in query expression 'routes.Start_time + INTERVAL stops.Min_from_start MINUTE'[/Quote]

 

I've tried playing around with it a bit but can't work out what it's after. Would be grateful for any help!

 

Regards

Link to comment
https://forums.phpfreaks.com/topic/186952-additions-in-sql/#findComment-987316
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.