如何在循环中执行此 MySql 语句
我会更复杂地编写我的命令行语句。如何使用循环来完成此操作?
update refs set custom_7 = '';
update refs set custom_7='1' where custom_7 = '' limit 220 ;
update refs set custom_7='2' where custom_7 = '' limit 220 ;
update refs set custom_7='3' where custom_7 = '' limit 220 ;
...
update refs set custom_7='100' where custom_7 = '' limit 220 ;
多谢。
I would write my cmd line statements more sophistically. How can this be done by using a loop?
update refs set custom_7 = '';
update refs set custom_7='1' where custom_7 = '' limit 220 ;
update refs set custom_7='2' where custom_7 = '' limit 220 ;
update refs set custom_7='3' where custom_7 = '' limit 220 ;
...
update refs set custom_7='100' where custom_7 = '' limit 220 ;
thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果有一列(例如
id
)定义了要更新行的行顺序,请使用ROW_NUMBER()
窗口函数对行进行排名并连接到表:如果没有像
id
这样的列,您可以从OVER()
子句中删除ORDER BY id
代码>ROW_NUMBER(),但是然后行将被任意更新。请参阅简化的演示。
If there is a column, like an
id
, that defines the order of the rows by which you want to update the rows, useROW_NUMBER()
window function to rank the rows and join to the table:If there is no column like the
id
, you may removeORDER BY id
from theOVER()
clause ofROW_NUMBER()
, but then the rows will be updated arbitrarily.See a simplified demo.
您可以尝试这样的操作(请将datatype(length)替换为custom7的类型)
You can try something like this (please replace datatype(length) with the type of custom7)