Mysql concatenation fields
update `users` set `email` = 'web+'.`id`.'@gmail.com'
Can i achieve 开发者_如何学运维this. Basically all that i am trying to do is updating email id in a special faction i.e insert the row's primary key between PLUS(+) and AT(@) in web+@gmail.com
Use CONCAT
:
UPDATE `users` SET `email` = CONCAT('web+', `id`, '@gmail.com' )
You should use CONCAT
function like this:
UPDATE `users` SET `email` = CONCAT('web+', CAST(id as CHAR), '@gmail.com')
Note you need to CAST
the id
to CHAR
for CONCAT
to work
精彩评论