INSERT INTO table [ (column_name,...) ] VALUES (expression,...) or INSERT INTO table [ (column_name,...) ] SELECT ...
An expression may use any previous column in column_name list (or table if no column name list is given).
The following holds for a multi-row INSERT statement:
ORDER BY clause.
INSERT statement cannot appear in the FROM
clause of the query.
INSERT INTO ... SELECT ... then one can get the following
info string with the C API function mysql_info().
Records: 100 Duplicates: 0 Warnings: 0 Duplicates are
rows which couldn't be written because some index would be
duplicated. Warnings are columns which were set to NULL, but have been
declared NOT NULL. These will be set to their default value.
In this case it's also forbidden in ANSI SQL to SELECT from the same table
that you are inserting into. The problem that there may be problems if
the SELECT finds records that is inserted at the same run. When using sub
selects the situation could easily be very confusing!
Go to the first, previous, next, last section, table of contents.