简体   繁体   English

使用基于该行的值更新表中的所有行?

[英]Update all rows in table with a value based on that row?

I want to quickly update a table to get rid of any real data that got pulled down to a test server. 我想快速更新一个表,以摆脱任何被拉到测试服务器的真实数据。

UPDATE users SET email = CONCAT ("fake", users.id, "@mycompany.org")

Is anything like that possible or will I need to write a script? 这样的事情是可能的还是我需要写一个脚本?

Yes, the query you are using will work. 是的,您正在使用的查询将起作用。 That is, for a row like: 也就是说,对于像这样的行:

id = 21
name = 'sth'
email = NULL

It'll update and set the email to: 它会更新并将电子邮件设置为:

'fake21@mycompany.org'

And similarly for all the rows in the entire table. 对于整个表中的所有行也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM