Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
"
INSERT INTO product list VALUES ('1', ' pencil','30','per box',' Apsara','11-12-2021',' 25 Rs,per box'). You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'list VALUES ('1', ' pencil','30','per box',' Apsara','11-12-2021',' 25 R...' at line 1
"what I do now

What I have tried:

i am trying to solve it from previous 7 days i didn't get any answer
Posted
Updated 21-Dec-21 4:23am

Assumng that your table is actually called "product list" with an embedded space, you need to add quotes in the SQL so the database engine understands it:
SQL
INSERT INTO 'product list' VALUES ('1', ' pencil' ...

And as you can see it is best not to create table names with embedded spaces.
 
Share this answer
 
If you have looked at that for seven days and not spotted it yet, you should probably reconsider your career choices ... a simple google would have told you the problem: INSERT - MariaDB Knowledge Base[^]
Since the error message explicitly says:
Quote:
check the manual that corresponds to your MariaDB server version for the right syntax to use near 'list VALUES ('1', ' pencil','30','per box',' Apsara','11-12-2021',' 25 R...' at line 1
It's obvious that "product list" is not a valid table name: Identifier Names - MariaDB Knowledge Base[^]
Which means all you had to do was quote the name:
SQL
INSERT INTO `product list` VALUES (...
 
Share this answer
 
Comments
Richard MacCutchan 21-Dec-21 9:40am    
I used ordinary single quotes; is that wrong?
OriginalGriff 21-Dec-21 10:23am    
Apparently MariaDB likes back quotes - unless you set ANSI_QUOTES SQL_MODE.
Furthermore, it is bad practice to have an INSERT statement that does not list the fields you want to assign values to. Your code will break as soon as someone adds fields to the table, or even changes the field order.

And then having numeric values in quotes looks like you are using strings everywhere which is also bad practice; you should use strings for text only, and use more specialized field types as appropriate (numeric fields for numbers, date fields for dates, etc). That allows smarter operations on your data, such as calculating MIN and MAX values, sorting chronologically, etc.

:)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900