【发布时间】:2019-01-10 10:23:04
【问题描述】:
我被查询困住了。场景是这样的: - 我需要为每个类别选择最多 4 个产品名称。 - 我正在使用这个查询,但它不能按我需要的方式工作 - 每个 cat_id 与 product_name 限制 4
结果将包含来自整个查询输出的 4 行。
$sql_course = "SELECT * FROM product WHERE cat_id IN('".$brand_filter."') ORDER BY cat_id LIMIT 4";
我想要这个
cat_id1- product1
cat_id1- product2
cat_id1- product3
cat_id1- product4
cat_id2- product5
cat_id2- product6
cat_id2- product7
cat_id2- product8
【问题讨论】:
-
您还想获得 cat_id 吗?结果
-
是的 cat_id 也
-
您当前的输出是什么,您可以在问题中添加快照吗?
标签: php