| Author |
update query wont work in mysql, column name to blame?
|
Kim Kantola
Ranch Hand
Joined: May 17, 2001
Posts: 274
|
|
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
Saloon Keeper
Joined: Oct 23, 2005
Posts: 3673
|
|
|
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.
|
My Blog: Down Home Country Coding with Scott Selikoff
|
 |
Kim Kantola
Ranch Hand
Joined: May 17, 2001
Posts: 274
|
|
|
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
Saloon Keeper
Joined: Oct 23, 2005
Posts: 3673
|
|
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
Joined: Dec 31, 2004
Posts: 961
|
|
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
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
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
Joined: Dec 31, 2004
Posts: 961
|
|
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
Saloon Keeper
Joined: Oct 23, 2005
Posts: 3673
|
|
Originally posted by Edwin Dalorzo: ...and it happens that MySQL does not support prepared statements
Ummmm... what driver are you using?
|
 |
 |
|
|
subject: update query wont work in mysql, column name to blame?
|
|
|