

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- Why does the following error occur in MySQL: ERROR 1062 (23000): Duplicate entry?
- Insert NULL value into INT column in MySQL?
- Insert default into not null column if value is null in MySQL?
- What is the proper way to insert an IF statement into a MySQL query?
- What MySQL returns if I insert invalid value into ENUM?
- Java application to insert null value into a MySQL database?
- How to correctly use INSERT INTO … SELECT in MySQL to avoid Error 1064?
- Why does MySQL refuse pipe ('|') character in string on INSERT INTO?
- Which PHP function is used to insert data into an existing MySQL table?
- How to insert DATE into a MySQL column value using Java?
- Insert JSON into a MySQL table?
- Why does comparing types in MySQL won’t raise an error?
- MySQL INSERT INTO SELECT into a table with AUTO_INCREMENT
- Insert NULL value into database field with char(2) as type in MySQL?
- Insert MAX(col)+1 into the same MySQL table?
Advertisements