且构网

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

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

更新时间:2022-12-11 23:33:55

这将做你想要的:

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

如果要包括table1的所有行。否则你可以添加一个WHERE语句到结尾,如果你只想添加一个table1的子集。

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.

我希望这有助于。