SQL INSERT INTO from multiple tables

You only need one INSERT:

INSERT INTO destinationTable( name, age, sex, city, id, number, nationality)
SELECT name, age, sex, city, s1.id, number, s3.nationality
FROM sourceTable1 s1
INNER JOIN sourceTable2 s2 ON s2.Id = s1.Id
INNER JOIN sourceTable3 s3 ON s3.Id = s1.Id

Leave a Comment