By 25/02/2016 1 Comments

What Is INSERT INTO SELECT Statement In SQL?

  • SQL INSERT INTO SELECT statement is used to copy records/data from one table and insert that data into another existing table.
  • When you use SQL INSERT INTO SELECT statement it inserts data into another table without affecting exist rows/records into other table.
  • By using SQL INSERT INTO SELECT statement you can copy all records/rows OR just selected rows into other table.

Syntax-1:

INSERT INTO table_2
SELECT * FROM table_1;

Syntax-2:

INSERT INTO table_2
(column_name(s))
SELECT column_name(s)
FROM table_1;

Example-1: Copy all records from products and insert into products_copy table.

INSERT INTO products_copy
SELECT *
FROM products;

Example-2: Copy only selected columns from products and insert into products_copy table.

INSERT INTO products_copy
(p_name, p_date)
SELECT p_name, p_date
FROM products;

Example-3: Copy only specific row from products and insert into products_copy table.

INSERT INTO products_copy
SELECT *
FROM products
WHERE p_id = 4;






Posted in: Sql

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .