Professional Web Applications Themes

Check for null query - Coldfusion Database Access

I have some code something like this in a query of a query: SELECT query1.field1, query1.field2, query1.field3 FROM query1 WHERE field1 not in (#QuotedValueList(query2.field1)#) I need to change that "WHERE" line to make this query run even if query2 is null. It currently doesn't work if query2 is null. I was thinking an OR statement would be needed, I just don't know what to put in it. Any help would be appreciated. Thanks....

  1. #1

    Default Check for null query

    I have some code something like this in a query of a query:

    SELECT query1.field1, query1.field2, query1.field3
    FROM query1
    WHERE field1 not in (#QuotedValueList(query2.field1)#)

    I need to change that "WHERE" line to make this query run even if query2 is
    null. It currently doesn't work if query2 is null. I was thinking an OR
    statement would be needed, I just don't know what to put in it. Any help would
    be appreciated. Thanks.

    T McDizzle Guest

  2. #2

    Default Re: Check for null query

    Only run it if query2 returned records.
    Dan Bracuk Guest

  3. #3

    Default Re: Check for null query

    Maybe something like the code below would work.


    SELECT query1.field1, query1.field2, query1.field3
    FROM query1
    <CFIF query2.RecordCount IS NOT 0>
    WHERE field1 not in (#QuotedValueList(query2.field1)#)
    </CFIF>

    jdeline Guest

Similar Threads

  1. Getting a 'Null Pointers' error when using query ofQueries
    By DaveLrs01 in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: April 26th, 02:26 PM
  2. how to to check array Null value on coldfusion 7
    By jiecoldfusion in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: February 28th, 02:36 PM
  3. CGI.pm form query sometime return null value
    By YesBalala in forum PERL Modules
    Replies: 2
    Last Post: February 13th, 06:23 PM
  4. Question: How check if datareader is null?
    By John Saunders in forum ASP.NET General
    Replies: 3
    Last Post: August 12th, 01:02 PM
  5. Check for Null In Conditional Formating
    By Allen Browne in forum Microsoft Access
    Replies: 1
    Last Post: August 1st, 01:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139