您的位置:首页 > 博客中心 > 数据库 >

MySQL将表a中查询的数据插入到表b中

时间:2022-03-10 18:15

MySQL将表a中查询的数据插入到表b中

如果表b存在

insert into b select * from a;

如果表b不存在

create table b as select * from a;

扩展:

将b表中的某写字段值插入到a表中

insert into a (userID,userName) select b.userID,b.userName from tr_ajax_chat_messages;

将a表和b表userID相等的值保存到a表

update a set a.userName=(select b.userName from b where a.userID = b.userID);


MySQL将表a中查询的数据插入到表b中,布布扣,bubuko.com

热门排行

今日推荐

热门手游