SQL编号栏-MySQL [英] SQL a numbering column - MySQL
本文介绍了SQL编号栏-MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个sql新手问题.
This is a sql newbie question.
基本上,我希望额外的一列与我的select语句一起返回以对行进行编号. 我正在使用mysql.
Basically, I want an extra column to return with my select statement to number the rows. I'm using mysql.
例如:
select * from friends
David
Steve
Joe
获取的语法是什么
1 David
2 Steve
3 Joe
推荐答案
来自: http://markmal.blogspot.com/2006/04/oracle-like-rownum-in-mysql.html
SELECT @rownum:=@rownum+1 rownum, t.*FROM (SELECT @rownum:=0) r, mytable t;
这篇关于SQL编号栏-MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文