following INSERT INTO statement:
INSERT INTO TABLE2 SELECT * FROM TABLE1
Now suppose you do not want to copy all the rows, but only those rows that meet a specific criteria. Say you only want to copy those rows where COL1 is equal to "A." To do this you would just modify the above code to look like this:
INSERT INTO TABLE2 SELECT * FROM TABLE1 WHERE COL1 = 'A'
See how simple it is to copy data from one table to another using the INSERT INTO method? You can even copy a selected set of columns, if you desire, by identifying the specific columns you wish to copy and populate, like so:
INSERT INTO TABLE2 (COL1, COL2, COL3)
SELECT COL1, COL4, COL7 FROM TABLE1
The above command copies only data from columns COL1, COL4, and COL7 in TABLE1 to COL1, COL2, and COL3 in TABLE2.