2 Replies Latest reply on Nov 9, 2007 1:00 PM by paross1

    If Null, do this....

      How do I test for a Null value? I have a query that returns the database fields, and in the output of the page, I want to include a little if statement where I can say if this one field is null, display a "No Value" message.

        • 1. Re: If Null, do this....
          Stressed_Simon Level 1
          Coldfusion cannot deal with nulls so if you return a null form the database it will get converted to an empty string.
          • 2. If Null, do this....
            paross1 Level 2
            Do you want to do this in the query or in ColdFusion? In the query itself, you can use whichever function is appropriate for your particular database to "convert" a NULL to some other value - NVL() in Oracle, ISNULL() in MSSQL, etc. Or, you can use <cfif> tags in the output and test the field to see if it is EQ to "" etc. and act accordingly.

            SELECT ISNULL(yourField, 'No Value') AS yourField
            FROM yourTable
            WHERE whatever