Master W3Schools SQL INSERT Statement: Syntax Examples and Best Practices

Logan Jul 13, 2026

The SQL INSERT statement is a powerful tool for adding new records to a database. If you're learning SQL, understanding how to use the INSERT statement is crucial. This article will walk you through the process, helping you to become proficient in using this essential SQL command.

W3Schools.com
W3Schools.com

The INSERT statement allows you to insert new rows into a table. Whether you're adding a new customer, a new product, or any other data, the INSERT statement is your key to populating your database.

DBMS and SQL statement - Select Insert Into a table command
DBMS and SQL statement - Select Insert Into a table command

Basic Syntax of the SQL INSERT Statement

The basic syntax of the INSERT statement is quite simple. It consists of the keyword 'INSERT', followed by the name of the table into which you want to insert data, and then the values you want to add.

SQl quick 1 min cheat sheet
SQl quick 1 min cheat sheet

Here's a basic example: 'INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ("Cardinal", "Tom B. Erichsen", "Skagen 21", "Stavanger", "4006", "Norway");'

Identifying the Table and Columns

Writing Basic SQL Select Statements With Actual Demonstration
Writing Basic SQL Select Statements With Actual Demonstration

In the 'INSERT INTO' clause, you specify the name of the table you want to insert data into. Following the table name, within parentheses, you list the columns you want to insert data into. If you omit the columns, MySQL will insert the data into all columns in the same order.

For example: 'INSERT INTO Customers (CustomerName, ContactName) VALUES ("Cardinal", "Tom B. Erichsen");' Here, only the CustomerName and ContactName columns will be populated.

Providing the Values

SQL Nested subquery - w3resource
SQL Nested subquery - w3resource

In the 'VALUES' clause, you provide the actual data you want to insert. Each set of values is enclosed in parentheses and is separated by commas. If you omit the 'VALUES' clause, an INSERT statement with no columns specified will insert records in the same order as the table columns.

For instance: 'INSERT INTO Customers VALUES ("Cardinal", "Tom B. Erichsen", "Skagen 21", "Stavanger", "4006", "Norway");' In this case, all columns are populated sequentially.

Inserting Multiple Rows

SQL in 60 days
SQL in 60 days

While the previous examples showed how to insert single records, you can also use the INSERT statement to insert multiple rows at once. This is done by listing the values for each row separated by commas.

Here's an example: 'INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ("Cardinal", "Tom B. Erichsen", "Skagen 21", "Stavanger", "4006", "Norway"), (" Schnellundschnitte GmbH", " Régine Navaugé", "Hochstr. 2", "Seattle", "98000", "USA");'

✨Aesthetic SQL Notes✨
✨Aesthetic SQL Notes✨
SQL
SQL
💻 SQL Basics Made Simple | Beginner-Friendly DBMS Notes
💻 SQL Basics Made Simple | Beginner-Friendly DBMS Notes
SQL Handwritten Notes 📘 | Basic SQL Commands for Beginners
SQL Handwritten Notes 📘 | Basic SQL Commands for Beginners
the text is written in black and white
the text is written in black and white
How do I write a basic SQL query?
How do I write a basic SQL query?
mastering sql joins made simple! 🔍✨ sql joins can be tricky, but here’s a visual guide to help you understand them all — from inner joins to right joins! knowing when to use each type can make your queries faster and cleaner. save this post for your next sql challenge! 🚀 👉 swipe to see how each type of join works and find the perfect one for your data needs! 📊 #sqljoins #sql #datascience #programming #coding #techieprogrammer #dataanalytics #learnsql #techtips #codenewbie #programminglife ... Sql Joins Tutorial For Beginners, Sql Join Performance Tips, Sql Joins Tutorial, Learn Sql Joins Online, Beginner's Guide To Sql Joins, Sql Self Join, Sql Joins Explained Visually, Sql Join Techniques, Sql Joins Tutorial Cover
mastering sql joins made simple! 🔍✨ sql joins can be tricky, but here’s a visual guide to help you understand them all — from inner joins to right joins! knowing when to use each type can make your queries faster and cleaner. save this post for your next sql challenge! 🚀 👉 swipe to see how each type of join works and find the perfect one for your data needs! 📊 #sqljoins #sql #datascience #programming #coding #techieprogrammer #dataanalytics #learnsql #techtips #codenewbie #programminglife ... Sql Joins Tutorial For Beginners, Sql Join Performance Tips, Sql Joins Tutorial, Learn Sql Joins Online, Beginner's Guide To Sql Joins, Sql Self Join, Sql Joins Explained Visually, Sql Join Techniques, Sql Joins Tutorial Cover
an image of some type of text on a white sheet with black and red writing
an image of some type of text on a white sheet with black and red writing
Impress Your Coworkers by Using SQL UNPIVOT!
Impress Your Coworkers by Using SQL UNPIVOT!
two pieces of paper with information about foreign and english writing on them, one has the words
two pieces of paper with information about foreign and english writing on them, one has the words
SQL Sheatsheet! 👍
SQL Sheatsheet! 👍
an image of a computer screen with some text on it
an image of a computer screen with some text on it
an image of a diagram with two circles
an image of a diagram with two circles
Surbhi Walecha on LinkedIn: 💡 Understanding How SQL Queries Work !! In the world of IT, we often…
Surbhi Walecha on LinkedIn: 💡 Understanding How SQL Queries Work !! In the world of IT, we often…
an info poster showing the different types of web pages and how they are used to create them
an info poster showing the different types of web pages and how they are used to create them
an image of a computer screen with text and numbers on the bottom right hand corner
an image of a computer screen with text and numbers on the bottom right hand corner
SQL Basics Cheat Sheet for Beginners | Learn SQL Fast 💻
SQL Basics Cheat Sheet for Beginners | Learn SQL Fast 💻
the worksheet is shown with numbers and symbols for each subject in this workbook
the worksheet is shown with numbers and symbols for each subject in this workbook
Learn SQL Fast 🚀 | Beginner SQL Commands Cheat Sheet for Data Analysts
Learn SQL Fast 🚀 | Beginner SQL Commands Cheat Sheet for Data Analysts

Using SELECT to Insert Rows

You can also use the SELECT statement to insert data into a table. This is often useful when you want to insert data from one table into another. Here's an example: 'INSERT INTO Customers (CustomerName, ContactName) SELECT CompanyName, ContactName FROM Suppliers WHERE Country='UK';'

This statement will copy the company name and contact name from the Suppliers table where the country is 'UK' and insert them into the Customers table.

Now that you've learned about the SQL INSERT statement, why not practice it on your own database? Diving in and trying out what you've learned is the best way to solidify your understanding. Happy coding!