Course

Multiple Inserts

Sometimes you'll want to add many values at once to your tables. For example, in a seeder file, you may want to insert several entries in your database at a time for demo and display data.

To do this, we follow the same syntax, except we can seperate each set of values with a comma. Just make sure the final set of values end in a semicolon.

ID (INT)name (VARCHAR)email (VARCHAR) (UNIQUE)createdAt (TIMESTAMP)updatedAt (TIMESTAMP)
1Amirsame@email.com2024-04-17 21:10:522024-04-17 21:10:52
2Jackiejackie@email.com2024-04-17 21:10:522024-04-17 21:10:52
INSERT INTO Users (name, email) VALUES
("Oscar","oscar@email.com"),
("Mario","mario@email.com"),
("Andrea","andrea@email.com");
ID (INT)name (VARCHAR)email (VARCHAR) (UNIQUE)createdAt (TIMESTAMP)updatedAt (TIMESTAMP)
Oscaroscar@email.com
Mariomario@email.com
Andreaandrea@email.com
ID (INT)name (VARCHAR)email (VARCHAR) (UNIQUE)createdAt (TIMESTAMP)updatedAt (TIMESTAMP)
1Amirsame@email.com2024-04-17 21:10:522024-04-17 21:10:52
2Jackiejackie@email.com2024-04-17 21:10:522024-04-17 21:10:52
3Oscaroscar@email.com2024-04-17 22:10:522024-04-17 22:10:52
4Mariomario@email.com2024-04-17 22:10:522024-04-17 22:10:52
5Andreaandrea@email.com2024-04-17 22:10:522024-04-17 22:10:52

0 Comments

"Please login to view comments"

glass-bbok

Join the Conversation!

Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.

Upgrade your account
tick-guideNext Lesson

Select - SQL