INSERT INTO ... SELECT
Copy, filter, and transform records directly from one table into another in a single high-speed statement.
INSERT INTO … SELECT is an essential topic in SQL and relational database engineering.
Overview
Building on foundational principles introduced in insert-into, mastering insert into … select provides the core mental model and practical query skills needed for production relational database engineering.
INSERT INTO archived_orders (order_id, customer_id, total, archived_at)
SELECT id, customer_id, total, CURRENT_TIMESTAMP
FROM active_orders
WHERE order_date < '2024-01-01';
Key Concepts
- Understand the fundamental syntax, conventions, and mental model.
- Avoid common beginner traps, data type mismatches, and performance pitfalls.
- Apply practical idioms directly in production applications.
[!TIP] Master this concept to build a rock-solid foundation. Next, proceed to update-statements.