newt
newt

Reputation: 309

mysql - insert into one table from another with conditions from a third table

How do you insert into table A all the rows from table B that match a condition from table C?

For instance,

INSERT INTO tableA SELECT * FROM tableB WHERE tableB.id=tableC.id;

This does not work, because mysql does not recognize tableC.

Upvotes: 1

Views: 1619

Answers (1)

bugwheels94
bugwheels94

Reputation: 31920

Then add tableC after From keyword and use tableB.* instead of *

 INSERT INTO tableA SELECT tableB.* FROM tableB,tableC WHERE tableB.id=tableC.id;

Upvotes: 1

Related Questions