选择递增整数
我想知道是否可以从mysql表中选择递增的整数?如果可能的话,我怎样才能实现这一目标?
我的情况是,我有一堆数据,我需要执行INSERT INTO newtable ... SELECT somefield FROM sometable
。但是,newtable
上有一个名为 counter
的字段,我需要它以递增整数的形式,例如:
row #1: counter=1
row #2: counter=2
row #3: counter=3
row #4: counter=4
row #5: counter=5
row #6: counter=6
... and so on...
我可以使用简单的 php 脚本来完成此操作,但我想尝试这样做这一切都来自mysql查询。那么,你们能告诉我这是否可能吗?
I want to know if it's possible to select incremented integer from mysql table? and if it does possible, how can I achieve that?
My case is, I have a bunch of data and I need to do INSERT INTO newtable ... SELECT somefield FROM sometable
. However, there is one field on newtable
called counter
that I need it in incremented integer, eg:
row #1: counter=1
row #2: counter=2
row #3: counter=3
row #4: counter=4
row #5: counter=5
row #6: counter=6
... and so on...
I can do this using simple php script, but I want to try to do it all from mysql query. So, can you guys tell me if it's possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this: