如何将多个序列号添加到 MySQL 中的一个 sql 视图中
我想做的是将多个序列号添加到 MySQL 中的一个 sql 视图中。考虑 下面的示例表:
Folder 1, File 1
Folder 1, File 2
Folder 2, File 3
Folder 3, File 4
Folder 3, File 5
Folder 3, File 6
我想要得到的结果是:
1, Folder 1, File 1
2, Folder 1, File 2
1, Folder 2, File 3
1, Folder 3, File 4
2, Folder 3, File 5
3, Folder 3, File 6
我知道如何使用变量将一个序列号添加到整个视图,但我不知道如何解决我的具体问题。希望有人能帮助我。
多谢!
干杯, 约翰内斯
what I would like to do is to add several sequence numbers to one single sql view in MySQL. Consider
the following example table:
Folder 1, File 1
Folder 1, File 2
Folder 2, File 3
Folder 3, File 4
Folder 3, File 5
Folder 3, File 6
What I would like to get as a result would be:
1, Folder 1, File 1
2, Folder 1, File 2
1, Folder 2, File 3
1, Folder 3, File 4
2, Folder 3, File 5
3, Folder 3, File 6
I know how I can add one single sequence number to the whole view using variables but I have no idea how to solve my specific problem. Hopefully someone can help me with that.
Thanks a lot!
Cheers,
Johannes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要使用一个变量,而是需要两个变量,只要组发生变化,就重置行编号。
Instead of using one single variable you will need two, reset the row numbering whenever the group changes.