
- 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
Why the following is showing an error in MySQL: INSERT INTO yourTableName VALUE(yourValue1,yourValue2,.......N);?
The error is in the syntax of VALUE().Use VALUES() instead of VALUE(). The correct syntax of the insert query is as follows −
INSERT INTO yourTableName VALUES(yourValue1,yourValue2,.......N);
Let us first create a table −
mysql> create table DemoTable ( StudentId int, StudentName varchar(40), StudentAge int ); Query OK, 0 rows affected (0.48 sec)
Insert some records in the table using insert command −
mysql> INSERT INTO DemoTable VALUES(1001,'Tom',20); Query OK, 1 row affected (0.11 sec) mysql> INSERT INTO DemoTable VALUES(1002,'Mike',21); Query OK, 1 row affected (0.13 sec) mysql> INSERT INTO DemoTable VALUES(1003,'Sam',19); Query OK, 1 row affected (0.08 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+-------------+------------+ | StudentId | StudentName | StudentAge | +-----------+-------------+------------+ | 1001 | Tom | 20 | | 1002 | Mike | 21 | | 1003 | Sam | 19 | +-----------+-------------+------------+ 3 rows in set (0.00 sec)
- Related Articles
- Insert NULL value into INT column in MySQL?
- Why does the following error occur in MySQL: ERROR 1062 (23000): Duplicate entry?
- How to correctly use INSERT INTO … SELECT in MySQL to avoid Error 1064?
- Insert default into not null column if value is null in MySQL?
- What MySQL returns if I insert invalid value into ENUM?
- Java application to insert null value into a MySQL database?
- Why does comparing types in MySQL won’t raise an error?
- What is the proper way to insert an IF statement into a MySQL query?
- How to insert DATE into a MySQL column value using Java?
- Why does MySQL refuse pipe ('|') character in string on INSERT INTO?
- Insert NULL value into database field with char(2) as type in MySQL?
- Which PHP function is used to insert data into an existing MySQL table?
- How to add static value while INSERT INTO with SELECT in a MySQL query?
- Insert JSON into a MySQL table?
- Fetch maximum ID value from the first table and insert to all the IDs in another table with MySQL INSERT INTO select?

Advertisements