TRENDING TOPICS

×

SQL INSERT INTO SELECT

The SQL INSERT INTO SELECT Statement used to copy data from one table and inserts it into another table

Syntax INSERT INTO SELECT

INSERT INTO table_2
SELECT * FROM table_1
WHERE [condition];

INSERT INTO SELECT Syntax [With COLUMNS]

INSERT INTO table_2 (column_1, column_2, column_3, ..)
SELECT (column_1, column_2, column_3, ..)
FROM table_1
WHERE [condition];

Query Statement Condition

  • The data type of columns must be same in source and target tables.
  • The target table existing records are unaffected.
  • The INSERT INTO Statement can also contains many clauses including SELECT, GROUP BY, HAVING, JOIN, and ALIAS; For Example:

INSERT INTO Example with Cluse

INSERT INTO table_2 (column_1, column_2, column_3)
SELECT column_1, column_2, column_3
FROM table_1
GROUP BY column_1, column_3;

Advertise With Us

We offer sponsored posts and guest posts with do-follow links, back-links, and other advertising services, To advertise email us at "advertise@gdatamart.com"

© 2021 GDATAMART.COM (All Rights Reserved)