🔍
👶 Kids📝 Blog About Contact 🚀 Get Started Free

SQL – INSERT INTO SELECT

Copy rows from one table into another existing table using INSERT INTO ... SELECT.

While CREATE TABLE AS SELECT creates a brand new table, INSERT INTO ... SELECT copies rows into an existing table. This is the go-to pattern for data migration, ETL (Extract, Transform, Load) pipelines, and merging data from multiple sources into a reporting table.

The SELECT can include any filtering, joining, or transformation — you can reshape and filter data as it is being copied, not just do a straight duplicate.

Syntax

INSERT INTO destination_table (col1, col2)
SELECT col1, col2
FROM   source_table
WHERE  condition;

Column count and types must be compatible.

Try It Yourself — Interactive SQL Editor

Edit the query below and click Run Query ▶ to see live results powered by SQLite running directly in your browser.

SQLite – edit & run
Results
← Click Run Query ▶ to see results

Key Points

  • Copies data into an existing table (unlike CREATE TABLE AS)
  • The SELECT can join, filter, and transform data
  • Column count must match between INSERT list and SELECT
  • Core pattern in ETL pipelines for loading data warehouses

Pro Tip from CodesCompiler: The best way to learn SQL is to break things intentionally — modify the query above, change the WHERE conditions, try different columns. Every error teaches you something the docs cannot.

In the next lesson, we continue exploring SQL’s powerful feature set to build your database mastery.