开发者

Transfer multiple rows from 1 table to another

I created a new table named Rate for rating posts from my Posts table. The Posts table already has data but Rate is empty. When I create a new post, its ID is added to Rate but there are many posts not added that were开发者_StackOverflow中文版 published before the Rate table.

What sort of query can I use to transfer multiple rows from Posts (just the ids) to the Rate table?


Use the MySQL INSERT ... SELECT for inserting data from one table to another. e.g.:

 INSERT INTO Rate (ID, col1, col2) SELECT ID, somecol1, somecol2 FROM Posts WHERE ....
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜