For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > March 2005 > Re: [PHP-DB] MySQL - Query within a query









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] MySQL - Query within a query
Larry E . Ullman

2005-03-19, 3:56 pm

> I am looking to do the following w/ MySQL and PHP. Have 1 query that
> gets
> results, then use those results in another query:
>
> $l = 2;
> $result1 = ("SELECT * FROM Drivers WHERE League = $l");
>
> $result2 = mysql_query("SELECT DriverID, Driver, CarNbr FROM Drivers
> LEFT
> JOIN $LeagueList ON Drivers.DriverID = $Result1.DriverID
> WHERE $Result1.DriverID) Is Null ORDER BY Drivers.DriverID");


If you're using MySQL 4.1, which supports subqueries, you might be able
to write this all up as one nice query (using a sub-select).

Larry
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com