Reputation: 1281
Full code I use:
$query18 = 'SELECT group_concat(id) as qc10 FROM tblorders WHERE date LIKE \'' . date ('Y-m-') . '%\'';
$result18 = mysql_query($query18);
$data18 = mysql_fetch_array($result18);
$qc10 = $data18['qc10'];
$query19 = "SELECT count(id) as qc11 FROM bl_orderitems WHERE orderid=$qc10";
$result19 = mysql_query($query19);
$data19 = mysql_fetch_array($result19);
$query19 looks like this:
'SELECT count(id) FROM bl_orderitems WHERE orderid=7,6,8,9,10,11,12,13,14';
But it doesn't work. How can I list those ID's so it would actually work?
THANKS!
Upvotes: 0
Views: 247
Reputation: 2928
Try using IN
SELECT count(id) FROM bl_orderitems WHERE orderid IN (7,6,8,9,10,11,12,13,14)
Upvotes: 3
Reputation: 1234
If you are looking to match a value for orderid that is one of those options that you listed, this should work:
SELECT count(orderid) FROM bl_orderitems WHERE orderid IN (7,6,8,9,10,11,12,13,14);
Upvotes: 2
Reputation: 4526
use WHERE orderid IN(7,6,8,9,10,11,12,13,14)
so the query would be:
'SELECT count(id) FROM bl_orderitems WHERE orderid IN(7,6,8,9,10,11,12,13,14)';
Upvotes: 5