Reputation: 438
I have following query which is not working with WHERE clause.Any help will be appreciated.
UPDATE abc SET
col1 = CASE
WHEN a1_date < now() THEN "xyz"
END,
col2 = CASE
WHEN a2_date < now() THEN "xyz"
END,
col3 = CASE
WHEN a3_date < now() THEN "xyz"
END
WHERE a1_date != NULL AND a2_date != NULL
Upvotes: 2
Views: 90
Reputation: 1567
To quote the MySQL Documentation
You cannot use arithmetic comparison operators such as =, <, or <> to test for NULL.
Therefore your comparison check right now will not work as intended.
To test for NULL, use the IS NULL and IS NOT NULL operators
Upvotes: 2
Reputation: 521194
Change your WHERE
clause to use IS NOT NULL
:
WHERE a1_date IS NOT NULL AND a2_date IS NOT NULL
Upvotes: 2