我想订购mysql查询的结果
1)首先显示与给定条件匹配并随机排序
2)然后显示按日期desc
排序的其余结果我已经尝试了这个:
Select * from post inner join user on post.user_id = user.id order by user.type = "top" desc, created desc;
非常感谢
答案 0 :(得分:1)
使用case
声明
select * from post
inner join user on post.user_id = user.id
order by case when user.type = 'top'
then 1
else 2
end asc,
created desc;