Cyber Junkie
Cyber Junkie

Reputation: 766

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 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?

Upvotes: 0

Views: 252

Answers (1)

shamittomar
shamittomar

Reputation: 46692

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 ....

Upvotes: 1

Related Questions