sql语句查询一个表里面无重复并且按照指定字段排序的sql语句

     


SELECT a.* FROM product_template a INNER JOIN (SELECT p_id,MAX(ID) as max_id FROM product_template where state >= 1
GROUP BY p_id DESC ) b ON a.p_id=b.p_id AND a.ID=b.max_id where a.p_id in ('207','229','46')

原文地址:https://www.cnblogs.com/thinkingandworkinghard/p/7541821.html