SELECT COUNT(*) FROM `product` where barcode in (681155,
681144,
681145,
681146,
681147,
681148,
688123,
688124,
688125,
688126) GROUP BY(barcode);
如何使用 count(*) 来执行此语句?我对所有行都得到 1
最佳答案
尝试:
SELECT COUNT(*) FROM `product`
where barcode in
(681155,
681144,
681145,
681146,
681147,
681148,
688123,
688124,
688125,
688126)
这将为您提供表格中的总数
当您使用 GROUP BY 时,它将对每个组进行计数。
SELECT barcode ,COUNT(*) FROM `product`
where barcode in (....)
Group by barcode
如果所有行都有一个,那么您的表格包含不同的条形码
关于mysql - 如何在mysql中使用count(*) WHERE IN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12315000/