If you query the first n records by each type separately

SELECT * FROM coin_shop a WHERE
(SELECT COUNT(*) FROM coin_shop b WHERE b.goods_type=a.goods_type AND b.cs_id>a.cs_id ) <2 

 

 

Check it out in this way, and display the top n of each type according to goods_type

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326095063&siteId=291194637