PHP/MYSQL Q

Hi,

I have 2 queries, I need the second to use the results from the first. Its a web based bus application using PHP&MYSQL.

the first query...

SELECT ROUTE_ID,COUNT(ROUTE_ID) AS numstops
FROM stop_visit_order,stop
WHERE stop_visit_order.STOP_ID=stop.STOP_ID
AND (STOP_DESC='VAR1') OR STOP_DESC='VAR2')
GROUP BY roue_ID
HAVING numstops 2;

I need to store the resulting ROUTE_ID's for the second query...

SELECT ROUTE_ID,ARRIVE_TIME
FROM stop_visit_time,stop
WHERE stop_visit_time.STOP_ID=stop.STOP_ID
AND STOP_DESC='VAR1'
AND stop_visit_time.ARRIVE_TIME>=#VAR3# AND ROUTE_ID IN (results from 1st query);

I am not sure how to do it, do I need to have a table in order to store these temp results (but this will mean only one user at a time and it is a web based application!)
or an array but how can MYSQL talk to it and incorporate it into the second query?

Thanks for the help.



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories