Searching for Null Values

When searching for user profiles, you might want to identify users who are “missing” an attribute value; for example, users who haven’t listed their birthday or users who haven’t designated a city or state. To search for missing values, use the keyword NULL. This syntax searches for users who haven’t entered a value for their birthday:

birthday = NULL

To return a collection of all the users who have supplied a value for the birthday attribute, use the != (not equal to) operator:

birthday != NULL

Two things to keep in mind here. First, NULL queries are only valid when using the = or the != operator; if you use NULL with any other operator (such as >) you’ll receive the following error message: ‘Null’ can only be used with exact matches.

Second, you must specify the NULL keyword using all uppercase letters. This query looks for all the user profiles that have not specified a country: = NULL

However, this query looks for all the users who live in the country Null: = Null

Definitely not the same thing.