我想显示dishname
和dishprice
,其中DISTINCT
值是第二高的dishprice
。
下面的查询有什么问题?
SELECT dishName, DISTINCT(dishPrice) FROM `tblDish` ORDER BY dishPrice LIMIT 1,1
最佳答案
如果同一价格有多个记录,则需要按价格分组,并对所有记录进行分组
SELECT GROUP_CONCAT(dishName), dishPrice FROM `tblDish` GROUP BY dishPrice ORDER BY dishPrice DESC LIMIT 1,1