Why am I getting this MySQL error - "Do you have an error in the SQL syntax ..."?

I get the following MySQL error:

You have an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to 'SET type =' movie ', SET category =' New ', SET music =' Pop ', SET' on line 1

Here is my request:

UPDATE music_content SET title = 'Classic', SET type = 'movie', SET category = 'New', SET music = 'Pop', SET audience = 'Everyone' WHERE id = '6' 

Not sure what I am doing wrong? - all columns and tables exist and all data is escaped (using mysql_real_escape_string ()). In addition, I have a live / connected MySQL connection.

MySQL Version: 5.1.41.

+4
source share
5 answers

UPDATE syntax uses only one SET even when updating multiple columns.

So try:

 UPDATE music_content SET title = 'Classic', type = 'movie', category = 'New', music = 'Pop', audience = 'Everyone' WHERE id = '6' 
+7
source

You only need to "SET" once:

 UPDATE music_content SET title = 'Classic', type = 'movie', category = 'New', music = 'Pop', audience = 'Everyone' WHERE id = '6' 
+1
source

You should have only one SET , for example:

 PDATE music_content SET title = 'Classic', type = 'movie', category = 'New', music = 'Pop', audience = 'Everyone' WHERE id = '6' 
+1
source

I think you only need one SET. Remove the rest and see if it works.

0
source

You have an abundance of SET in your application. Drop everything except the first. See the UPDATE Syntax documentation for more information.

0
source

Source: https://habr.com/ru/post/1333727/


All Articles