The SELECT INTO statement inserts data from one table to another table. The syntax is: SELECT INTO target table [field list] FROM source table [WHERE condition]. Can be used to create new tables, move or update data.
SELECT INTO statement usage
The SELECT INTO statement allows you to select data from one table and insert it into another in a table. The syntax is:
<code>SELECT INTO 目标表 [字段列表] FROM 源表 [WHERE 条件]</code>
Syntax description:
Usage:
The SELECT INTO statement is used for the following purposes:
Example:
Copy a table:
<code>SELECT INTO 新表 * FROM 旧表;</code>
Insert certain fields into the new table :
<code>SELECT INTO 新表 (字段1, 字段2) FROM 旧表;</code>
Update existing table:
<code>SELECT INTO 表名 (字段1, 字段2) FROM 另一个表 WHERE 表名.主键 = 另一个表.主键;</code>
Note:
The above is the detailed content of select into statement usage. For more information, please follow other related articles on the PHP Chinese website!