do1sqlselect命令,只对表中的前100条记录起作用

ecfdbz9o  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(227)

我的问题是,当我执行select命令时,应用程序非常慢,因为我执行select from table时有10000条记录,但我总是只处理大约前100条记录。是否有选项说Doselect,但不是从所有表中选择-例如。是否从表中选择,但仅处理前100条记录?

$time = mysql_query("KBD, jobNumber, truckid, SUM(pallets) as count_pallets, SUM(cartons) as count_cartons, COUNT(*) as pocet FROM incoming WHERE availableDate = '$today_date' AND slotTime = '$time' GROUP BY truckid,forwarder");
34gzjxbg

34gzjxbg1#

您可以通过在末尾添加limit子句来限制mysql中的记录数量。

$time = mysql_query
("KBD, jobNumber, truckid, SUM(pallets) as count_pallets, 
SUM(cartons) as count_cartons, COUNT(*) as pocet 
FROM incoming 
WHERE availableDate = '$today_date' 
AND slotTime = '$time' 
GROUP BY truckid,forwarder 
LIMIT 100"
);

相关问题