• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

update query wont work in mysql, column name to blame?

 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All, I am trying to run the following query using mysql :

update alerttable set status=4 where status=0

The update does not happen. I am suspecting that it may be because I have the column named "status", is "status" a reserved word ? When I run the query, I do not get an error message, but the rows with status equal to zero stay at the value zero. The status column is defined as a tinyint.

I tried to pick a differant column of the table and rerun the query and it works fine , it just wont seem to work on this column. The column is not an index or key or anything like that.

Any tips? Thanks!
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Status is not a reserved word in MySql. Try re-typing the query by hand and/or removing the "where status = 0" clause and see if that works.
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much. I wonder if something wierd is going on with my sqlYog app which is what I am using to run the query. I tried to run it again on a differant database I had , and this time it worked. Not sure what is up, but I do appreciate your input ! Thanks for letting me know that status is not a reserved mysql word.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a link to all reserved words (thanks google!):

http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using prepared statements to run the query. I onced suffered a few hours with that in MySQL, and it happens that MySQL does not support prepared statements, therefor it simply ignores the query and does nothing.

It really pissed me off, because it worked fine in PostgreSQL.

Maybe that helps!
 
Paul Clapham
Sheriff
Posts: 21559
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Edwin Dalorzo:
...and it happens that MySQL does not support prepared statements...
Good thing I didn't know that. Because I have an application that uses PreparedStatements to read and update a MySQL database. It works fine and has been working fine for several years now.
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, the prepared statement feature is present since version 4.1. Then it could be a good idea to check anyway.
[ July 25, 2006: Message edited by: Edwin Dalorzo ]
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Edwin Dalorzo:
...and it happens that MySQL does not support prepared statements


Ummmm... what driver are you using?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic