有时候order by有这种需求:需要某个userid的数据排在第一行,然后再跟进其他字段进行order by 。 怎么处理这种需求。可以这么用:

 

select * from user order by 

case when userid =xx then  0 else userid end --我们把userid等于指定数值的设置为0这样就在前面,

case when xxx 这里还可以继续排序

 

参考:https://blog.csdn.net/a258831020/article/details/50159551/

相关文章:

  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-02-25
猜你喜欢
  • 2021-07-08
  • 2021-07-05
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案