飞道的博客

Mysql查询一张表的数据新增到另一张表里

359人阅读  评论(0)

1.把B表的数据查询出新增到A表去

INSERT INTO a(id,name) 
SELECT  b.id as id,b.name as name FROM b;

2.B表的字段满足不了A的情况下
‘name’是对应type ,now()是对应的create_date

INSERT INTO dim_attach (type,bill_id,url,create_date) select  'name',  a.id AS bill_id, a.head_address AS url,now()
FROM
 dim_people a

转载:https://blog.csdn.net/weixin_44520739/article/details/109182598
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场