SELECT INTO

The SQL statement SELECT INTO is used to select data from a table and copy another table differently.

It is often used to make a backup of data in a table.

SQL SELECT INTO syntax

SELECT * FROM INTO newtable FROM table

This statement will copy all records from the table 'table' on table 'newtable'.

The new table can even be in a different database

SELECT *
INTO newtable [IN newdatabase]
FROM table

If we make a backup of a table in another

SELECT * INTO peopleBackup FROM people

You can also select only some columns

SELECT column1, column2 INTO peopleBackup FROM people

You can also include a condition (WHERE)

SELECT * INTO peopleBackup FROM people WHERE name = 'HARRY'

You can use SELECT INTO with JOIN

SELECT people.name, people.surname, departamentos.departamento INTO peopleComputer FROM people INNER JOIN departments ON people.dep = 'COMPUTER'