Home > Database > Mysql Tutorial > body text

How do we add values ​​to columns of MySQL table?

WBOY
Release: 2023-09-09 20:53:02
forward
735 people have browsed it

我们如何向 MySQL 表的列添加值?

The INSERT command is used to add values ​​to columns of a MySQL table. We need to specify values ​​for all the columns in the INSERT command as shown below-

Syntax

INSERT INTO table_name values(value1,value2,…)
Copy after login

Example

Suppose we have a table named "Stock" where Contains three columns "Item_id", "Item_name" and "Item_rate" then with the help of the following query we can add values ​​in these columns.

mysql> INSERT INTO Stock values(1,'HistoryBook',250);
Query OK, 1 row affected (0.07 sec)

mysql> INSERT INTO Stock values(2,'DBMSBook',280);
Query OK, 1 row affected (0.10 sec)

mysql> Select * from Stock;
+---------+-------------+-----------+
| item_id | Item_name   | Item_rate |
+---------+-------------+-----------+
| 1       | HistoryBook | 250       |
| 2       | DBMSBook    | 280       |
+---------+-------------+-----------+
2 rows in set (0.00 sec)
Copy after login

The above is the detailed content of How do we add values ​​to columns of MySQL table?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template