1,某條數據放首位,其他倒序並分頁 select * from Student order by( case when id='2' then 1 ELSE 4 END),id desc limit 0,5; 2,給查詢的每條記錄添加編號 select (@i:=@i+1) no , s.* fro ...
1,某條數據放首位,其他倒序並分頁
select * from Student order by(
case
when id='2' then 1
ELSE 4
END),id desc limit 0,5;
2,給查詢的每條記錄添加編號
select (@i:=@i+1) no , s.* from Student s , (select @i:=0) as i