Quantcast
Channel: mysql – blog.azwan.net
Viewing all articles
Browse latest Browse all 17

MySQL insert into select

$
0
0

This SQL statement to be used to insert data into a table from another different table.

1
2
3
INSERT INTO table1 (field1)
  SELECT table2.field2 FROM table2 
  WHERE table2.field2 > 100;

Be careful with ambiguous fields. So put the table name in front of the field name.
Also be careful with duplicate data inserted to the table.


Viewing all articles
Browse latest Browse all 17

Trending Articles