Easy Tutorial
❮ Sql Dates Sql Hosting ❯

SQL SELECT INTO Statement


With SQL, you can copy information from one table to another.

The SELECT INTO statement copies data from one table and then inserts it into a new table.


SQL SELECT INTO Statement

The SELECT INTO statement copies data from one table and then inserts it into a new table.

>

Note:

MySQL databases do not support the SELECT ... INTO statement, but they do support INSERT INTO ... SELECT.

Of course, you can use the following statement to copy both the table structure and data:

CREATE TABLE new_table
AS
SELECT * FROM old_table

SQL SELECT INTO Syntax

We can copy all columns into the new table:

Or we can copy only the desired columns into the new table:

| | Tip: The new table will be created with the column names and types defined in the SELECT statement. You can use the AS clause to apply new names. | | --- | --- |


SQL SELECT INTO Examples

Create a backup copy of Websites:

Copy only some columns into the new table:

Copy only websites from China into the new table:

Copy data from multiple tables into the new table:

Tip: The SELECT INTO statement can be used to create a new empty table by another pattern. Simply add a WHERE clause that causes the query to return no data:

❮ Sql Dates Sql Hosting ❯