sql

sql基础语句示例

sql的基本操作示例供参考

Posted by catface on January 5, 2015

基础语句

开发总结语句

排序并置顶

按column_a排序并按条件将column_b某条置顶/底

1
select * from test order by case when username='catface' then 0 else 1 end, update_time asc;

1
select * from test order by instr('catface', username) desc, update_time asc;

分页排序并置顶

1
select * from test order by case when username='catface' then 0 else 1 end, update_time desc limit 2 offset 2;