Null Comparison in MySQL -


I was trying to compare prices in some areas using case in mysql I got strange behavior because I tried the following query it is giving me wrong in mysql I can not find the reason behind it. Any help? Select if (tap = null, 'true', 'false');

From MySQL documentation on this page:

Unless you use it, the real value can be surprising, conceptually, NULL means "unavailable unknown value" and it is done differently from other values.

Since the NULL is "unknown", the comparison NULL = NULL will also become unknown and the return tap, and when the tap is not correct, then your function will return 'false'.

You can use the IS Null operator:

  if selected (tap is tap, 'true', 'false')  

Or you can still use:

  Select if (zero <=> NULL, 'true', 'wrong')  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -