SELECT...INTO Statement Examples

SQL statement

Description

 

SELECT Employees.*
INTO [Emp Backup]
FROM Employees;

Selects all records in the Employees table and copies them into a new table named Emp Backup.

SELECT Employees.*
INTO Trainees
FROM Employees
WHERE Title = 'Trainee';

Creates a new table that contains only employee records that have the title Trainee.

SELECT Employees.*
INTO Employees
IN "BACKUP.MDB"
FROM Employees;

Makes a copy of the Employees table and places the new table in the BACKUP database.

SELECT Employees.*, Salary
INTO Trainees
FROM Employees, Payroll, Employees
INNER JOIN Payroll
ON Employees.[Employee ID] = Payroll.[Employee ID]
WHERE Title = 'Trainee';

Creates a new table that contains employee and payroll data for all trainees.  The Employees and Payroll tables have a one-to-one relationship.  The new table contains all of the data from the Employees table, plus the Salary field from the Payroll table.