insert into where mysql code example

Example 1: myql insert from select

INSERT INTO table_name(column_list)
SELECT 
   select_list 
FROM 
   another_table
WHERE
   condition;

Example 2: Insert mysql

#Some columns or all 
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
#All columns
INSERT INTO table_name
VALUES (value1, value2, value3, ...);

Example 3: insert into table from another table mysql

INSERT INTO table1 (emp_id, fname)
SELECT emp_id, fname 
FROM table2
WHERE status = 'Active';

Tags:

Sql Example