[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? [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 |
| 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 |