1. 程式人生 > >sql查詢中,增加序號

sql查詢中,增加序號

oracle中有rownum函式,可以直接使用。例如:

select rownum as 序號t.city_name as 城市t.city_address as 地址 from ct_exh_city t order by t.exh_city_id asc;


mysql中沒有rownum函式,

select @n:[email protected]+1 as 序號, t.* from bd_city t, (select @n:=0) d;