How to insert more than one record SQL statements

When using SQL databases, we might need a database like to add many records, then we can use the SQL statement to be implemented, the statement is as follows:

- add a record
INSERT INTO tableName (col1, col2, col3) VALUES (1,2,3)

- Add multiple records
INSERT INTO tableName (col1, col2, col3)
the SELECT 3,4,5
UNION ALL
the SELECT 6,7,8

- a further read from a plurality of data added to the table to a new table in
the INSERT the INTO tableName (col1, col2, col3)
the SELECT A, B, C on tableA the FROM

- read from the other plurality of tables to add data to the new table,
the INSERT the INTO tableName (col1, col2, col3)
the SELECT A, B, C the FROM on tableA the WHERE A =. 1
the UNION ALL
the SELECT A, B, C the FROM on tableB the WHERE A = 2
the upper side into the code can be omitted!
Union all upper code if changed Union, the same recording only once inserted, the insertion will not be repeated.

 

Original link https://zhidao.baidu.com/question/534866520.html

Guess you like

Origin www.cnblogs.com/sunny3158/p/11315445.html