常见的sql语句解决方案
作者:互联网
1 排序的时候优先某一部分(关注置顶)
产品分页,如果产品ID在(265,249,146,262,261),优先置顶分页这部分数据。
然后再考虑其他,再按照创建时间倒序。
SELECT *
FROM product
ORDER BY id IN (265,249,146,262,261) DESC, create_time desc
LIMIT 10;
select * from product ORDER BY id in (104,259,256,6) desc , create_time desc limit 10
标签:语句,146,解决方案,create,id,sql,ORDER,置顶,desc 来源: https://www.cnblogs.com/hellosiyu/p/15687290.html