user4072401 user4072401 - 1 month ago 6
MySQL Question

MySQL Error 1064 (42000) when running UPDATE query

Can anyone tell me what is wrong with this MySQL query?

Query:

UPDATE MATERIAL_MASTER SET MST_NAME='XXX' MAT_DESC='YYY' MAT_TYPE='Raw Material' MAT_GRP='H' UOM='kg' CURRENCY='inr' ENTITY_ASSEMBLED='A' where idMATERIAL_MASTER=3;


Error:


1064 (42000): 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 'MAT_DESC='YYY' MAT_TYPE='Raw Material' MAT_GRP='H' UOM='kg' CURRENCY='inr' ENTIT' at line 1

Answer

In this:

UPDATE MATERIAL_MASTER 
SET MST_NAME='XXX' MAT_DESC='YYY' 
MAT_TYPE='Raw Material' 
MAT_GRP='H' UOM='kg' CURRENCY='inr'
ENTITY_ASSEMBLED='A'
where idMATERIAL_MASTER=3;

You're missing commas between fields in SET zone.

The correct query is:

UPDATE MATERIAL_MASTER 
SET MST_NAME='XXX', MAT_DESC='YYY', 
MAT_TYPE='Raw Material', 
MAT_GRP='H', UOM='kg', CURRENCY='inr',
ENTITY_ASSEMBLED='A'
where idMATERIAL_MASTER=3;