Search⌘ K

Insert Product Data

Explore how to insert product data into a MySQL table with automatic ID assignment, then learn to count total and filtered records using SQL queries to verify your insertions and manage data effectively.

We'll cover the following...

Insert data

Now that the table is ready, let’s insert a new product:

MySQL
insert into products(name, price) values ('Game of Thrones-S01-DVD', 50.0);

In the insert statement above, we first specify the columns we’ll give values for. Then, we provide the values themselves and get a Succeeded response because there’s nothing to display.

Let’s double-check that the product has been created:

MySQL
select * from products;

When we run the code above, we get the following output:

+----+-----------------------------+-------+
| id | name                        | price |
+----+-----------------------------+------
...