Reputation: 554
I want set some records in my database. There is some records where field last_login is less than create_at. So, I wanna set the field last_login_at this records with NULL.
But, the query below its not working.
update database.users
set last_login_at = NULL
where last_login_at < created_at;
I do some tests, the query below works:
SELECT * FROM database.users
WHERE last_login_at < created_at;
And this query works too:
UPDATE database.users
SET last_login_at = NULL
WHERE id = 10;
Why the first query doesn't work?
Upvotes: 3
Views: 1237
Reputation: 54212
created_at
is not equal to create_at
. Error is due to a typo.
Change to this:
update database.users
set last_login_at = NULL
where last_login_at < created_at;
Upvotes: 1