hinch
10-04-2011, 04:37 PM
At the moment I select from one table where an ID column is part of another tables contents.
I was doing it as 2 separate queries ie: doing the sub select first then implode() into a comma separated string then doing the 2nd select with a loop.
Then as part of my query tidying up I changed to as below.
SELECT ID,GGInternalID FROM `tblsites` WHERE ID IN(SELECT SiteID FROM `tblkeyclientstosites` WHERE KeyClientID=".$sessionArr[3].") AND DatePrepared BETWEEN '$startdate' AND '$enddate'
My question is is there a faster / better way of doing things than a sub select like this.
I was doing it as 2 separate queries ie: doing the sub select first then implode() into a comma separated string then doing the 2nd select with a loop.
Then as part of my query tidying up I changed to as below.
SELECT ID,GGInternalID FROM `tblsites` WHERE ID IN(SELECT SiteID FROM `tblkeyclientstosites` WHERE KeyClientID=".$sessionArr[3].") AND DatePrepared BETWEEN '$startdate' AND '$enddate'
My question is is there a faster / better way of doing things than a sub select like this.