我想在我的mysql查询
中选择下面mysql查询中minprice的确切IDSelect min(p.Price) as minprice,GROUP_CONCAT(p.vendor_id) as v_ids,p.*
from my_table as p GROUP BY `SKU` order by Price ASC
我也试过这个
Select min(p.Price) as minprice,
GROUP_CONCAT(p.PRODUCT_ID) as IDS,
GROUP_CONCAT(p.Price) as prices,
GROUP_CONCAT(p.vendor_id) as v_ids,p.* from `my_table` as p
GROUP BY `SKU` order by Price ASC
但它并没有帮助我
请获取minprice的ID
提前致谢
答案 0 :(得分:1)
SELECT MT.* FROM MY_TABLE MT
INNER JOIN
(
SELECT PRODUCT_ID ID,SKU,MIN(P.PRICE) FROM MY_TABLE GROUP BY PRODUCT_ID,SKU
)Z ON Z.ID=MT.PRODUCT_ID AND Z.SKU=MT.SKU
您可以尝试以上代码。
这会对你有帮助。