SQL Select Statement Question

Hey all, how do you word a SQL Select statement where you want to search for a field with a Nil value? So I have a field that I use sometimes, but when I don’t use it, the value is Nil. How do I search for that in SQL? I want the query to be something like:

SELECT * FROM ThisTable WHERE UnitID = 1 and MySometimesField = Nil

Thanks!

... field IS NULL

1 Like

THANK YOU! I was trying

field = NULL

But that wasn’t working. Yours works!

Should be is Nil. (or perhaps Null)

No Nil value is equal to another.

1 Like

NULL is a weird thing. You can’t use “=” on it, and you can’t compare a NULL field to anything either. Some databases (maybe all, I don’t know) also offer IS DISTINCT FROM and IS NOT DISTINCT FROM that will work with null fields and values, albeit generally slower.