MYSQL

How to INSERT data from one Table into another in MySQL

If You want to insert one table selected data from another table. there are some syntax for insert data. Using an INSERT…SELECT statement, we can insert multiple rows of data into a table, with the result of a SELECT statement which can get data from one or more tables.

Use the following MYSQL query to insert data from one table to another in MySQL.

INSERT INTO insert_table_name(A, B, C)
  SELECT A, B, C
    FROM select_table_name

Here are Syntax for insert one table to another table like insert_table_name (target_table) and select_table_name (source_table)

INSERT INTO 
    employee_master (emp_name, city, state, zip_code) 
SELECT
    emp_name,
    city,
    state,
    zip_code
FROM
    employee_details
WHERE
    city IN ('Lucknow', 'Kanpur')

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Close
Back to top button