我有这个查询:
update sales_flat_quote set customer_email = (concat(select substring(md5(rand()) from 1 for 20), '@example.com'));
它给了我这个错误:3 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 6 行 SQL1.sql 6 1 的 '' 附近使用的正确语法。我想将子字符串 select 的结果与静态 @example.com 字符串连接起来。
查询有什么问题?
谢谢!
最佳答案
select substring(md5(rand()) from 1 for 20
返回结果集,而不是字符串。
执行您想要的操作的正确方法是 update sales_flat_quote set customer_email = (concat(substring(md5(rand()) from 1 for 20), '@example.com'));
关于MySql:使用 concat 不起作用,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10582567/