Mysql – SQL Syntax Error – Unsure if it is empty value or backslash

MySQL

I am getting a syntax error when the following query is being run:-

 INSERT INTO mw_reward_point_order VALUES(9477,0,0,144,,'100/1')

I originally thought it was because there was an empty value between the two , as I can manually populate the empty value like below and it works fine:-

 INSERT INTO mw_reward_point_order VALUES(9477,0,0,144,1,'100/1')

But I am not entirely sure, as the error reads SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use **near ''100/1')'** at line 1, query was: INSERT INTO mw_reward_point_order VALUES(9477,0,0,144,,'100/1')

Please could someone point out what exactly the syntax error is? Is it the lack of value between the two commas or in fact the backslash in the last value – possibly not being escaped?

Best Answer

If you want to omit a column you can either apply a column list:

INSERT INTO mw_reward_point_order (col_1,col_2col_3,col_4,col_6)
VALUES(9477,0,0,144,'100/1')

or specify NULL:

INSERT INTO mw_reward_point_order VALUES(9477,0,0,144,NULL,'100/1')