Given the R table containing the following data:
  a  |  b
------------
  1  | NULL
NULL | NULL
NULL |  2
  3  |  4
What will the following query return?
SELECT COUNT(*) 
FROM R 
WHERE a = NULL OR a IS NOT NULL
Explanation
NULL values should be checked using IS NULL and IS NOT NULL operators only.
In cases of other comparisons the result may vary between different database management systems, nut it will be UNDEFINED in most of the cases.
If а = NULL evaluates to UNDEFINED then SQL handles it according to the following logic:

FALSE OR UNDEFINED = UNDEFINED
TRUE OR UNDEFINED = TRUE

Therefore, the condition will be met only by two records from the table.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты