In MSSQL Server, we make queries for null values like below:
SELECT name, ISNULL(about, ''), contact FROM `user_profile` WHERE userid=1
But when I am开发者_StackOverflow社区 trying to do the same with MYSQL then it gives error.
What is the logical and easy way to handle NULL values in php/mysql scenario.
Thanks
It's IFNULL() for MySQL ^^ But in your case it seems you can return a NULL value, just use a condition to test it.
if(!$result['valuemaybenull']) -> true if 0, false or NULL
Be cautios about the following in MySQL:
SELECT 1=NULL returns NULL SELECT 1!=NULL return NULL (as well)
Whenever you want to check for null values use the IS NULL expression (or the above IFNULL)
精彩评论