I accidentally sent it before finishing... I am looking for a way to do the following with a single query: > SELECT `ID`, `Name`, `Interface`, > (SELECT count(*) FROM CONCAT('listings_', `ID`) WHERE `Status`='Active') as > `activeListings` > FROM `sites` >
I am querying the sites table and I want to have a field showing active listings. Each row in the sites table has a corresponding 'listings' table. so a site where `ID`=1 will have a listings_1 table. If I want to return data from 100 sites is there a way to get the active listings count without making 100 extra querys?