The way you're trying to do it is completely wrong!
You should avoid of copying data row-by-row (record-by-record), due to tons of reasons.
If the structure of tables is the same, you can use
INSERT INTO[
^]:
INSERT INTO Table4 (Field1, Field2, ... FieldN)
SELECT Field1, Field2, ... FieldN
FROM (
SELECT Field1, Field2, ... FieldN
FROM Table1
UNION ALL
SELECT Field1, Field2, ... FieldN
FROM Table2
UNION ALL
SELECT Field1, Field2, ... FieldN
FROM Table3
) A
In case you need to get data from 3 tables and they are related, you need to use
JOIN
:
INSERT INTO Table4 (Field1, Field2, ... FieldN)
SELECT Field1, Field2, ... FieldN
FROM (
SELECT t1.Field1, t2.Field2, ... t3.FieldN
FROM Table1 t1
INNER|OUTER|LEFT|RIGHT JOIN Table2 t2 ON t1.PrimaryKey = t2.ForeignKey
INNER|OUTER|LEFT|RIGHT JOIN Table3 t3 ON t2.PrimaryKey = t3.ForeignKey
) A
For further details, please see:
Visual Representation of SQL Joins[
^]