- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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)
Advertisements