This question already has an answer here:
这个问题在这里已有答案:
- How to copy data from one table to another new table in MySQL? 11 answers
如何将数据从一个表复制到MySQL中的另一个新表? 11个答案
user table: id | facebookid | externalid | more data...
用户表:id | facebookid | externalid |更多数据......
userexternalid table: id | userid | facebookid | externalid
userexternalid表:id | userid | facebookid |外部ID
What I need is to write a query that gets all data from the user table and inserts is as following for every single row.
我需要的是编写一个查询来获取用户表中的所有数据,并为每一行插入如下内容。
userexternalid.userid = user.id
userexternalid.facebookid = user.facebookid
userexternalid.externalid = user.externalid
Can't seem to find anything like it on the web. Anyone an idea? Thanks
似乎无法在网上找到类似的东西。有人有想法吗?谢谢
1 个解决方案
#1
INSERT INTO userexternalid (userid, facebookid, externalid)
SELECT id AS userid, facebookid, externalid FROM user;
#1
INSERT INTO userexternalid (userid, facebookid, externalid)
SELECT id AS userid, facebookid, externalid FROM user;