I have extremely strange problem, which drives me crazy all day. I have a simple MySQL table with few columns. One column is int(11) NULL. When I update its value, it works as expected. However, when I update its value second time, it gets assigned "0" value.
I have tested this same behaviour on my MySQL 5.1.58-1ubuntu1 and on other MySQL 5.0.96-community and both behave exactly the same. So it apparently is not problem of one version MySQL.
It is difficult for me to explain, but I have attached 2 screenshots which will tell you much better where is the better.
First screenshot is structure of my table I am updating:
And here is shown SQL queries beeing executed, where you can see, that first update is correct and the second produces "0" value in column "invoice_number" with no reason:
Am I overlooking something obvious ? It really drives me crazy, because it doesn't make any sense to me...
Thank you for any help in advance...
EDIT: I have tried using only numbers in my queries and this is result (very strange for me as well):
USE GEEKSFORGEEKS; Output: To have the latest updated records, we should have a column such as “last updated” with the “Timestamp” column in any table and when a record is newly inserted, it should get the current timestamp value for that column.
Specific columns can be modified using the SET clause by supplying new values for that column. The WHERE clause can be used to specify the conditions those identify which rows to update. Without using WHERE clause, all rows are updated. The ORDER BY clause is used to update the order that is already specified.
This isn't an answer, but the comments are getting crowded. The behavior you show does indicate some sort of problem, however more likely in the tool you are using to interface to the database rather than in the database.
The issue with the single quotes is a red herring (i.e. distraction). Even if '55' were interpreted differently from 55, it would be interpreted the same way in the where
statement. Also, '35' worked but '30' didn't.
A key insight is the failure when you remove the quotes. The statement:
update i_orders
set invoice_number = 30
where id = 55
should not be looking up a column index for 30. The unknown column error you are seeing suggests that the query sent to the database is not the one you see in the tool.
Can you log the queries in the database to see what is actually being sent in?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With