Another SQL gotcha
Yesterday I was working on the sample app for a 'soon to be announced' new framework. I needed to query to get all records with a null value in a numerical field.
Here's what I tried at first:
FROM forum_messages
WHERE msgParentID = NULL
Problem was that it did not return any rows, but also did not throw any error. For a second I beleived that it must be something in the my application code that was wrong, but I threw the code into the SQL Query Analyzer and still got zero rows returned.
Of course the answer was not further away than a quick Google search, and what I found was that I needed to change my SQL to this:
FROM forum_messages
WHERE msgParentID IS NULL
If you are interested in the why of this you can read about it here


where col <=> <cfqueryparam ... null="#NOT isNumeric(myVar)#" />
Without that operator, you have to do this:
<cfif isNumeric(myVar)>
where col = <cfqueryparam ... />
<cfelse>
where col IS NULL
</cfif>