请帮我解决这个问题
我想得到较小的 PandaCode
作为输出,我有一个 PandaCode
Array
(
[0] => 37860
[1] => 37016
[2] => 37013
[3] => 38220
[4] => 38420
[5] => 38223
)
每个PandaCode
代码都有多个id
例如 37860
有 count(id)=3 这样每个 Pandacode
都有 id
和不同值的计数,但我想得到 PandaCode
作为输出的 id
数量较少
foreach($pandacode as $dealer_code){
$query="SELECT COUNT(id) FROM `dealer_details`
WHERE `PandaCode` like '$dealer_code' and `Senttime` like '%$today%'";
$result=mysqli_query($conn,$query);
$row = $result->fetch_assoc();
$size = $row['COUNT(id)'];
}
最佳答案
如果我以正确的方式理解您的问题而不是添加 whereIn 而不是为每个问题添加 whereIn,请尝试此操作
SELECT COUNT(id) as ids FROM `dealer_details` WHERE `PandaCode` IN ($pandacode) and `Senttime` like '%$today%' GROUP BY `PandaCode` ORDER BY ids ASC LIMIT 1
关于php - 获取 less count id 的 PandaCode 作为输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40481291/