0
update cometchat set read='1' where id='18'

SQL Error 156:Incorrect syntax near the keyword 'read'.

Can you guys help me how do I do that?

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98

3 Answers3

2

Read is a reserved word. You need to escape it. Also, if the values are integers, you should not use the single quotes around them.

If It's Sql Server (and it is, based on the error message), you need to use square brackets:

update cometchat set [read]=1 where id=18

In MySql, your query should look like this:

update cometchat set `read`=1 where id=18 
Zohar Peled
  • 79,642
  • 10
  • 69
  • 121
0

You shouldn't put quotes around int values in your query as it converts them to type string.

Should I quote numbers in SQL?

UPDATE cometchat SET `read`=1 WHERE id=18

**Edit: You're also using a reserved keyword, and need to escape it, see:

https://dev.mysql.com/doc/refman/5.5/en/keywords.html

Community
  • 1
  • 1
Kaylined
  • 655
  • 6
  • 15
0

Seriously...

UPDATE cometchat SET `read`=1...

"read" is a restricted keyword. It needs to be quoted.

junkfoodjunkie
  • 3,168
  • 1
  • 19
  • 33