MySql:使用 concat 不起作用,为什么?

标签 mysql substring concatenation

我有这个查询:

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/

相关文章:

MySQL 查询按日期分组

php - 如果链接值为 1,则如何激活链接;如果为 0,则链接未激活,请使用单选按钮

java - java中的连接循环

python - CNN : images and parameters, 的多个输入如何合并

javascript - 时间值的 Jquery 串联

php - mysql编程的好方法

php - MySQL/PHP : Returning the row values that contain the MAX value

Java内联方法/截断字符串的策略?

java - 打印文件来源的文件夹名称

java - 为什么这个子字符串问题返回 false?