4

I'm getting the following MySQL error:

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 'SET type = 'movie', SET category = 'New', SET music = 'Pop', SET' at line 1

Heres my query:

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'm doing wrong? - all the columns and tables exist and all the data is escaped (using mysql_real_escape_string()). Furthermore I have a valid/connected MySQL connection.

MySQL Version: 5.1.41.

1
  • If i'm not wrong: SETs doesn't have to be separated by a , at all. Commented Dec 29, 2010 at 19:54

5 Answers 5

7

The UPDATE syntax uses only one SET even when multiple columns are being updated.

So try:

UPDATE music_content 
SET title = 'Classic',
type = 'movie',
category = 'New',
music = 'Pop',
audience = 'Everyone' 
WHERE id = '6'
Sign up to request clarification or add additional context in comments.

Comments

1

You only need to have "SET" once:

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

Comments

1

You should only have one SET, like so:

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

Comments

0

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

Comments

0

You have an abundance of SET's in your statement. Drop all but the fist one. For more information, please see the UPDATE Syntax documentation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.