Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use INSERT INTO SELECT in SQL

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 280
    Comment on it

    By using INSERT INTO SELECT Statement one can copy data from one table to other existing table.
    Syntax:

    To copy all the columns from one table to another table:

    INSERT INTO table_name1  (SELECT * from table_name);

    To copy only the selected columns:

    INSERT INTO table_name1(column_names)  (SELECT column_names from table_name);

    Above, both table_name and table_name1 are existing table where:
    table_name: is the table from which you will copy the data.
    table_name1: is the table in which you want to insert the copied data.


    Example:

    INSERT INTO temp_employee (SELECT * from employee);

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: