09-23-2011, 11:05 AM
|
#3 (permalink)
|
|
The Wanderer
Join Date: May 2010
Posts: 19
Thanks: 1
|
This two queries can be easely merged in to one.
Quote:
Originally Posted by hmonkey89
select * from stocklevel where jobID = $jobID GROUP BY catID
then for each
count(*) from stock where catID = $catID
|
Code:
SELECT stocklevel.*, COUNT(catID) AS numCats
FROM stocklevel
LEFT JOIN stock USING(catID)
WHERE jobID = '$jobID' GROUP BY catID
But English is not what I am best at and I couldn't understand what are you trying to do with the dates
Quote:
Originally Posted by hmonkey89
get all dates between startdate and enddate
|
startdate and enddate of stocklevel or jobs? What do you want to compare this dates with?
|
|
|
|