When you are working with different types of databases (MSSQL, MySQL, Oracle, …), you tend to forget the syntax for some logic you want to implement.

Today I’m going to list different statements on how to insert multiple rows with a single statement.
Let’s say that we have a table, called “User”. Our table contains 3 fields: “UserId”, “UserName”, “Email”. Now we can start adding some rows.

Inserting multiple rows in MSSQL

INSERT INTO [User]
SELECT NULL, 'Mike', 'mike.bevers@spider-projects.com'
UNION ALL
SELECT NULL, 'Simba', 'simba@catland.com'
UNION ALL
SELECT NULL, 'Sasha','sasha@catland.com'

Inserting multiple rows in MySQL

INSERT INTO `User` VALUES
(NULL, 'Mike', 'mike.bevers@spider-projects.com'),
(NULL, 'Simba', 'simba@catland.com'),
(NULL, 'Sasha', 'sasha@catland.com');