A Single SQL Syntax for Data Insertion Between Tables
Moving data from one table to another is a frequent database operation. While most database systems support this, remembering the specific syntax for each can be difficult. Fortunately, a standard SQL approach works across many systems:
<code class="language-sql">INSERT INTO table1 (column1) SELECT col1 FROM table2;</code>
This inserts data from selected columns in the source table (table2
) into the corresponding columns of the target table (table1
).
Confirmed Functionality:
This method has been successfully tested on these database systems:
The above is the detailed content of How Can I Universally Insert Data from One Table to Another Using SQL?. For more information, please follow other related articles on the PHP Chinese website!