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)

Updated on: 04-Oct-2019

91 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements