Mysql insert into select , update select 操作

有时候需要把查询到的数据直接插入另一个表中,sql如下:
insert into a
(a.aid, a.name)
select id, name from b
where b.xx = xx

更新操作如下:
UPDATE ta SET name = ( SELECT a.name
FROM a
WHERE ta.aid = a.id )
WHERE ta.pid = xx

内容追加:
update ta set name = CONCAT(name, 'str') WHERE id = xx //CONCAT 追加字段内容

你可能感兴趣的:(Mysql insert into select , update select 操作)