1

I've came across strange issue. I know I'm missing something very minor. Can Any One solve the problem plz. This is my table:

     cat_id name              desc
        1   Cricket Schedule     
        2   Live Cricket      Live Cricket Desc
        3   Fixtures     
        4   Videos   

I ran following update query and worked fine.

UPDATE cats 
set name='New Fixtures' 
WHERE cat_id='3'

But When I Run Following Query, It returns error:

#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 'desc='New Fixtures Desc' WHERE cat_id='3'' at line 1

The Query is :

UPDATE cats 
set desc='New Fixtures Desc' 
WHERE cat_id='3'

Plz Tell me What I am Missing Here

John Woo
  • 258,903
  • 69
  • 498
  • 492
Nandla
  • 207
  • 3
  • 13

1 Answers1

0

desc is a reserved keyword, you must escape it with backtick

UPDATE cats 
set `desc` = 'New Fixtures Desc' 
WHERE cat_id = '3'
John Woo
  • 258,903
  • 69
  • 498
  • 492
  • UPDATE cats set desc='New Fixtures descriptive Text' WHERE cat_id='3' this is not working too – Nandla Nov 19 '12 at 05:43
  • Should I change the name of Column instead ?? – Nandla Nov 19 '12 at 05:43
  • you may if you want (*to prevent headache in the future*) :D but you can still use that provided that you escaped it with backtick, see example above. – John Woo Nov 19 '12 at 05:44
  • Thank you Every one. Problem Fixed after changing column Name from desc to anything else as desc is reserved word. – Nandla Nov 19 '12 at 05:46