[nycphp-talk] Need help understanding NULL

lists at lists at
Sat Aug 29 22:16:26 EDT 2009

John Campbell wrote:
> You should be aware that PHP and SQL have completely different concepts of null.
> In php, null is a unique magic value that means "undefined", and if
> two things are null, then they are equal.


> In a SQL view of the world, that can be interpreted as:
> Are two not yet known values equal?
> and the answer is:
> "Not yet known"
> In sql, every comparison to NULL, yields another NULL.
> That is why 'SELECT * WHERE foo = NULL' doesn't do what you might
> expect.  In fact that query is guaranteed to always return zero rows.

OMG, having this info solves a big piece of the puzzle for me--thank you!

> It is a fact of life that pretty much every language handles NULL
> differently, and whenever I learn a new language, it is one of the
> first things I research.

I'll keep that in mind.


More information about the talk mailing list