1、要求将所有email为空的字段值改成phone连接字符串@qq.com的格式
#这是单独执行一条数据
SELECT * FROM user_list
where id=30;
update user_list
set email=concat(phone,’@qq.com’) where id=30;
#批量执行多条数据
SELECT * FROM user_list
where email=’’;
update user_list
set email=concat(phone,’@qq.com’) where email=’’;
2、mysql下sql语句令某字段值等于原值加上一个字符串
update 表明 SET 字段= ‘feifei’ || 字段; (postgreSQL 用 || 来连贯字符串)
MySQL连贯字符串不能利用加号(+),而利用concat。
比方在aa表的name字段前加字符’x’,利用:
update aa set name=concat(‘x’,name)
所有的name值前就会多一个x的字符