Reputation: 21
I'm trying to do a simple mysql update statement, or at least i thought it was a simple update statement. It's executing successfully, but it doesnt match the condition is specify and wont update the table... can anyone see what im doing wrong?
update messagequeue set timesent = curtime() where deviceid = '1231231237' and timesent = NULL
there are 4 columns in the table and 1 row.
id, message, deviceid, timesent
the timesent is default null.
the deviceid is '1231231237'
id = 1
message is just some junk....
the query just doesnt work :(
Upvotes: 2
Views: 119
Reputation: 20830
UPDATE messagequeue SET timesent = curtime() WHERE deviceid = '1231231237' AND timesent IS NULL
NULL wont work as you defined, Use IS NULL check instead.
Also check datatype 'deviceid' . If it is Int, then don't use single quotes with it, use it like this :
UPDATE messagequeue SET timesent = curtime() WHERE deviceid = 1231231237 AND timesent IS NULL
Upvotes: 1
Reputation: 3730
Right. '=' doesn't work with NULL so you should use 'IS NULL' as in Sebas's answer.
Upvotes: 1
Reputation: 21522
update messagequeue set timesent = curtime() where deviceid = '1231231237' and timesent IS NULL
Upvotes: 3