我有一个包含以下字段的表格
id, date, featured
特征是0或1
我想先排序我的MySQL表是否具有功能(功能= 1),然后再按日期对其余表进行排序。 我只能一个人订购。
这是我当前的SQL语句
SELECT * FROM listings ORDER BY featured = 1 DESC, date DESC
答案 0 :(得分:1)
SELECT * FROM listing ORDER BY verified DESC, date DESC
从查询中删除= 1
答案 1 :(得分:-1)
听起来您想选择经过验证(verified = 1
),然后按日期排序(最近的日期为DESC
)。您可能想要:
SELECT * FROM listing WHERE verified = 1 ORDER BY date DESC