Reputation: 21
I am sturggling to get the following query working:
UPDATE user_stock SET user_stock1 = user_stock2
WHERE user_stock1 = NULL AND user_id = 'mike';
The query is accepted with no syntax errors, although it does not set user_stock1 to the value of user_stock2, any ideas?
Upvotes: 2
Views: 1622
Reputation: 5397
In SQL, a column is never equal to NULL
. You have to use IS NULL
or IS NOT NULL
:
UPDATE user_stock SET user_stock1 = user_stock2
WHERE user_stock1 IS NULL AND user_id = 'mike';
Upvotes: 3