Reputation: 282895
In MySQL, you can write something like
INSERT INTO t1 (col1) SELECT col1 FROM t2
To copy some data over. What if I want to copy some data over from multiple tables? Can I write something like
INSERT INTO t1 (col1) SELECT col1 FROM t2, SELECT col1 FROM t3
?
Upvotes: 0
Views: 677
Reputation: 9425
i think it should be
INSERT INTO t1 (col1) SELECT col1 FROM t2 UNION SELECT col1 FROM t3
EDIT: Now before you go copying data, you may want to verify using
UNION
vs UNION ALL
UNION will remove duplicates in the data. UNION ALL will produce a simple concatenation of the two result sets.
Upvotes: 2