select (select count(*) from 表 where 主键<=a.主键) as 行号,a.* from 表 a order by 主键
--id可以是你的唯一字段,你可以参考下面: select (select count(*) from t where id<=a.id) 编号,* from t a order by idselect (select count(*) from t where id>=a.id) 编号,* from t a order by id desc
select (select count(*) from t where id<=a.id) 编号,* from t a order by idselect (select count(*) from t where id>=a.id) 编号,* from t a order by id desc