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:
SELECT INTO 目标表 [字段列表] FROM 源表 [WHERE 条件]
Syntax description:
Usage:
The SELECT INTO statement is used for the following purposes:
Example:
Copy a table:
SELECT INTO 新表 * FROM 旧表;
Insert certain fields into the new table :
SELECT INTO 新表 (字段1, 字段2) FROM 旧表;
Update existing table:
SELECT INTO 表名 (字段1, 字段2) FROM 另一个表 WHERE 表名.主键 = 另一个表.主键;
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!