[MDEV-16361] Update WHERE condition null Created: 2018-05-31  Updated: 2018-05-31  Resolved: 2018-05-31

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: None
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Elvis P dos Reis Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Amazon RDS MariaDB 10.2.12



 Description   

Is this behavior correct?
I'm trying to make an update with the condition v.fk_status != 17 and in the database the value v.fk_status is null

[SQL] UPDATE vendas v SET v.data_cancelamento = '2018-05-31 10:27:27', v.fk_status = 17 WHERE v.id_venda = 531476 AND v.fk_status != 17

Affected rows: 0
Time: 0.012s



 Comments   
Comment by Elena Stepanova [ 2018-05-31 ]

Naturally, NULL != 17 returns NULL, so there is no match. Is what you meant, or what bothers you in the result?

Comment by Elvis P dos Reis [ 2018-05-31 ]

I'm doing an update in the field that is different 17 of course null is different from 17 but the condition is not accepted, I would have to test AND (v.fk_status! = 17 OR v.fk_status IS NULL) or COALESCE (v.fk_status, 0)! = 17)

Comment by Elena Stepanova [ 2018-05-31 ]

Yes, that's exactly what you need to do when you work with NULLs. Please read documentation, e.g. here: https://mariadb.com/kb/en/library/null-values/#comparison-operators
Or, if you suspect that it's MariaDB invention, you can find the same in MySQL manual.

Generated at Thu Feb 08 08:28:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.