Inserting Results of a Select into a table

Sometimes you must insert the results from a Select statement into an existing table. As long as the data types correspond with each other, data from one or more tables can easily be inserted into another table. The basic syntax is shown here:

INSERT INTO destination (fieldname1, fieldname2, .

.. fieldnameN)

SELECT fieldname1, fieldname2, ... fieldnameN

FROM source

[WHERE criteria]

If you wanted to insert the entire contents of the tblContacts table into a tblContactsArchive table, you could use the following statement:

INSERT INTO tblContactsArchive SELECT * FROM tblContacts

Alternatively, you could list each field.

0 0

Post a comment