Mysql 更新500+;字段记录包括一个增量值+;属性值
我希望在我的mysql数据库中更新500多条记录,这样字段将是Mysql 更新500+;字段记录包括一个增量值+;属性值,mysql,sql,Mysql,Sql,我希望在我的mysql数据库中更新500多条记录,这样字段将是$incremental\u value+db\u user\u first\u name+@some\u static\u text的值组合。预期结果的一个例子: 一,_firstname@staticstring.com, 2_george@staticstring.com, 3_johnny@staticstring.com等等 我一直在使用下面的一些方法,但这自然不起作用(为了更好的澄清而进行了修改) MySQL中字符串连接的
$incremental\u value+db\u user\u first\u name+@some\u static\u text
的值组合。预期结果的一个例子:
一,_firstname@staticstring.com, 2_george@staticstring.com, 3_johnny@staticstring.com等等
我一直在使用下面的一些方法,但这自然不起作用(为了更好的澄清而进行了修改)
MySQL中字符串连接的正确语法是
concat()
函数:
UPDATE user cross join
(select @i = VALUETOSTART) var
SET email = concat(@i := @i + 1, '_', user.first_name, '@staticstring.com')
WHERE email = 'empty@empty.com';
UPDATE user cross join
(select @i = VALUETOSTART) var
SET email = concat(@i := @i + 1, '_', user.first_name, '@staticstring.com')
WHERE email = 'empty@empty.com';