我使用的完整代码:
$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如下所示:
'SELECT count(id) FROM bl_orderitems WHERE orderid=7,6,8,9,10,11,12,13,14';
但它不起作用。如何列出这些ID,以便实际工作?
谢谢!
答案 0 :(得分:5)
使用WHERE orderid IN(7,6,8,9,10,11,12,13,14)
所以查询将是:
'SELECT count(id) FROM bl_orderitems WHERE orderid IN(7,6,8,9,10,11,12,13,14)';
答案 1 :(得分:3)
尝试使用IN
SELECT count(id)FROM bl_orderitems WHERE orderid IN(7,6,8,9,10,11,12,13,14)
答案 2 :(得分:2)
如果您希望匹配orderid的值,这是您列出的选项之一,则应该有效:
SELECT count(orderid) FROM bl_orderitems WHERE orderid IN (7,6,8,9,10,11,12,13,14);