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

2023-04-12编程技术248389

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中的相关教程结束。

本文地址:https://www.ufcn.cn/tutorials/2453532.html

如非特殊说明,本站内容均来自于网友自主分享,概不代表本站观点,如有任何问题我们都将在收到反馈后的第一时间进行处理!