请帮我解决此问题
我希望得到更小的PandaCode
作为输出,我有一个PandaCode
Array
(
[0] => 37860
[1] => 37016
[2] => 37013
[3] => 38220
[4] => 38420
[5] => 38223
)
每个PandaCode
代码都有多个id
个
例如37860
有计数(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)'];
}
作为输出
listView=(ListView)findViewById(R.id.listview);
Scanner s = null;
try {
s = new Scanner(new BufferedReader(new FileReader("/storage/sdcard0/client_new.txt")));
final ArrayList<String> list = new ArrayList<String>();
while (s.hasNext()) {
String str = s.next();
char[] myChar = str.toCharArray();
System.out.println(myChar);
String str_new = String.valueOf(myChar);
String[] items={str_new};
for (int i = 0; i < items.length; ++i)
{
list.add(items[i]);
}
Toast.makeText(ExistingContacts.this,str_new,Toast.LENGTH_LONG).show();
ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_dropdown_item,list);
listView.setAdapter(adapter);
}
}catch (Exception e)
{
e.printStackTrace();;
}
答案 0 :(得分:0)
如果我以正确的方式理解您的问题,而不是添加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