Inserting Data from Another Table


# General syntax for INSERT ... SELECT INSERT table_one (list, of, columns) SELECT ...;



The INSERT command can be combined with a SELECT command to allow easy copying of rows from one table to another table.

The syntax is very simple. Take the front part of the INSERT command (up to the VALUES clause) and graft a SELECT command to it. Just make sure that the SELECT returns one column for every column that the INSERT command requires.

This example shows the general syntax for the INSERT ... SELECT command. For a more complex example that demonstrates a practical use of this feature, see phrase "Splitting a Column into Its Own Table" in Chapter 5, "Manipulating Data."



MySQL Phrasebook. Essential Code and Commands
MySQL Phrasebook
ISBN: 0672328399
EAN: 2147483647
Year: 2003
Pages: 130

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net