K
K
Katerina Paskova2019-12-09 13:07:14
MySQL
Katerina Paskova, 2019-12-09 13:07:14

Why is SQL query not capturing NULL rows?

Hello, I don't understand what is the problem. There is a small table in MySQL with countries. It has a currency_code field with currency codes.
5dee1c184cfe8776538677.png
I'm trying to get all countries whose currency is not Euro (code 978) using the following query: But for some reason you don't get records with NULL, although it is logical that they are not equal to 978. Why is this happening and how to overcome it? Tried !=, still doesn't work. Thank you!
SELECT * FROM country WHERE currency_code <> 978

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2019-12-09
@KatyaPaskova

NULL in the muscle is not null, it is a separate data type not included in the comparative ranges and must be checked separately, that is, you need to addor currency_code IS NULL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question