开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜