What is the difference b/w PHP null value and Mysql database field null value
I encountered a problem while fetching database field value which is basically a null value
I tried
SELECT * FROM table WHERE field=''; //this means null in php
and
SELECT * FROM table WHERE field IS NULL; //this means null in mysql db
Both queries are producing different result.
What is the difference b/w both null values and how can be the null valu开发者_开发技巧es different?
When querying the database, definitions from PHP are thrown out the window. In SQL, "" represents an empty string.
In PHP programming, the difference between null, zero, false, and empty string easily becomes ambiguous because of PHP's == vs. ===. Oracle, MSSQL, and MySql (sometimes?) are a lot more strict in this respect.
PHP, as a high-level language, allows loose comparisons, as described by PHP type comparison tables.
精彩评论