开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜