
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we add values into the columns of a MySQL table?
INSERT command is used to add values to the columns of a MySQL table. We need to specify the values in INSERT command for all the columns as follows −
Syntax
INSERT INTO table_name values(value1,value2,…)
Example
Suppose we have a table named ‘Stock’ with three columns ‘Item_id’, ‘Item_name’ and ‘Item_rate’ then with the help of 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)
- Related Articles
- How can we add columns with default values to an existing MySQL table?
- How can we alter table to add MySQL virtual GENERATED COLUMNS?
- How can we alter table to add MySQL stored GENERATED COLUMNS?
- How can we combine the values of two or more columns of MySQL table?
- How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?
- How can we import only specific columns from the text file, into MySQL table?
- How can we insert values into a table with the help of MySQL self-computed output?
- How can we add multiple columns, with single command, to an existing MySQL table?
- How can we insert data into a MySQL table?
- How can we update values in a MySQL table?
- How can I return the values of columns from MySQL table as a set of values?
- How can we update the values in one MySQL table by using the values of another MySQL table?
- How can we get a list of columns in an existing MySQL table?
- How can we set PRIMARY KEY on multiple columns of a MySQL table?
- How can we insert a new row into a MySQL table?

Advertisements