Jump to content

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.