Part 6: Mastering INSERT INTO SELECT
Mastering INSERT INTO SELECT
How to copy records from one table into another using SQL β archiving filtered business data, populating reporting tables, and automating data movement.
Learning Objectives
- Use INSERT INTO SELECT to copy records from one table into another using a SELECT query
- Create the destination table with the correct structure before running INSERT INTO SELECT
- Add a WHERE clause to the SELECT to copy only filtered subsets of records
- Understand that INSERT INTO SELECT copies data β the source table remains unchanged
Students often assume that the message “Query ran successfully. No rows were returned” means something went wrong. In fact, this usually means the database completed the requested action successfully.
When using INSERT INTO … SELECT, the goal is to copy data, not display it. The database performs the insert operation, but it does not automatically show the inserted records.
Key Point: If an INSERT INTO … SELECT statement returns “Query ran successfully. No rows were returned,” the operation likely worked correctly. The message indicates that data was copied, not that data was displayed. Students should run a separate SELECT query if they want to view the inserted records.
INSERT INTO SELECT copies records from one table into another table using a SELECT query to define which records to copy. The destination table must already exist before running INSERT INTO SELECT. The SELECT can include a WHERE clause to copy only filtered subsets, or no WHERE clause to copy all records.
In industry, analysts use INSERT INTO SELECT to move operational data between tables, create backup records before making changes, replicate filtered business information into reporting tables, archive completed or historical records, and transfer data between systems as part of ETL (Extract, Transform, Load) workflows.
The destination table must already exist before the INSERT runs. The number of columns in the INSERT INTO clause must match the number of columns in the SELECT. The data types must be compatible between source and destination columns.
Each INSERT INTO SELECT practice follows a two-step pattern: first create the destination table with the correct structure, then run the INSERT INTO SELECT to populate it. In production environments, destination tables are typically created once and reused; in practice exercises, DROP TABLE IF EXISTS ensures a clean start before each run.
Step 1: CREATE TABLE target_table (columns and types). Step 2: INSERT INTO target_table (columns) SELECT columns FROM source_table. The CREATE defines the structure; the INSERT populates it. Always confirm column names and data types match before running.
Adding a WHERE clause to the SELECT inside INSERT INTO SELECT copies only the matching records. Completed orders only. Active subscriptions only. Open tickets only. Email campaigns only. This filtered copying is the most common INSERT INTO SELECT pattern in business analytics β populating an archive or reporting table with only the records that meet a specific business criterion.
INSERT INTO completed_orders_archive … SELECT … FROM orders WHERE order_status = βCompletedβ copies only the 6 completed orders. The other orders are not copied. WHERE applies to the SELECT, not to the INSERT.
INSERT INTO SELECT is the foundation of database-level reporting workflows. Active subscriptions copied to a reporting table. Refund transactions isolated in a separate table. Software products extracted to a product-type archive. These patterns replace manual data exports with automated, reproducible SQL operations that run on a schedule or on demand.
When running INSERT INTO SELECT practice queries more than once, the destination table may already exist from a previous run. DROP TABLE IF EXISTS table_name before CREATE TABLE removes the old table cleanly so the exercise can be repeated without errors.
Each practice has two steps: create the destination table, then run the INSERT INTO SELECT. Use DROP TABLE IF EXISTS at the start of each exercise to ensure a clean run.
Knowledge Check
Five questions β select the best answer for each.
Part 6 Summary
The key ideas from this lecture β keep these in mind as you move forward.
INSERT INTO SELECT helps analysts copy, archive, and replicate business records between tables as part of operational workflows and ETL processes. Create the destination table first. WHERE filters which rows are copied. Source data is never changed.

