="insert into t_gk_mapping(id,gk_project_name,gk_project_code,main_project_name,main_project_code) values ('"&J2&"','"&I2&"','"&K2&"','"&L2&"','"&M2&"');"
复制代码
为name字段拼接 值
update user set name = concat(name,'test') where 1=1
复制代码
REPLACE()字符串函数 更换函数
UPDATE
student
SET
name = REPLACE(name,'小明','小红')
WHERE
id = '1';
复制代码
关联表,将匹配到的数据另一个表的字段set到当前表字段中
update t1,t2 set t1.`name` = t2.class_name where t1.id = t2.id
复制代码
将表中一个字段的值更新为另一个字段的值 (自连接)
update student a,student b set a.name = b.class
where a.id = b.id
复制代码
根据number删除重复记录,保留code较小的数据
delete from t1 where id in
(
select * from
(select id from t1
where number in (select number from t1 group by number
having count(number) > 1)
and code not in (select min(code) from t1 group by number having