mysql获取行号的方法

1.不排序

语句:

SELECT (@rowNum:=@rowNum+1) AS rowNo,bigquestion.bigQuestionSequence FROM (SELECT (@rowNum :=0) ) b,bigquestion

 

结果:

 

 2.排序的

语句

select (@rowNum:=@rowNum+1) as rowNo,bigquestion.bigQuestionSequence from (Select (@rowNum :=0) ) b,bigquestion order by bigquestion.bigQuestionSequence

 

结果:

 

posted @ 2017-10-30 14:24  QiaoZhi  阅读(2119)  评论(0编辑  收藏  举报