且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将数据从一个表复制到 MySQL 中的另一个新表?

更新时间:2022-12-11 23:38:43

这将满足您的需求:

INSERT INTO table2 (st_id,uid,changed,status,assign_status)
SELECT st_id,from_uid,now(),'Pending','Assigned'
FROM table1

如果您想包含 table1 中的所有行.否则,如果您只想添加 table1 的子集,则可以在末尾添加 WHERE 语句.

If you want to include all rows from table1. Otherwise you can add a WHERE statement to the end if you want to add only a subset of table1.

我希望这会有所帮助.