macromedia.coldfusion.database_access
[Top] [All Lists]

Ignoring Rows with Empty Fields?

Subject: Ignoring Rows with Empty Fields?
From: "silstorm" <webforumsuser@xxxxxxxxxxxxxx>
Date: Mon, 28 Jul 2008 16:03:45 +0000 (UTC)
Newsgroups: macromedia.coldfusion.database_access

I have an existing query, and would like to limit the results according to 
whether one of the fields (which is an optional field in a form) has a value.

 I've been looking through some similar threads here and came up with the 
following;

 <cfquery name="getsimilar" datasource="#datasource#" maxrows="5">
             SELECT catshortname, soshortname, retailer_name
             FROM merchants
             WHERE 1 = 2
                        <cfif len(trim(getsimilar.soshortname)) GT 0>
                        OR soshortname IN (<cfqueryparam 
cfsqltype="CF_SQL_VARCHAR"
                        value="#getsimilar.soshortname#" list="yes">)
                        </cfif>
             AND catshortname='#getmerchant.catshortname#'
             ORDER BY retailer_name ASC
             </cfquery>

 However, I get an error when executing this.

 The field I want to be sure has a value is 'soshortname'

 Any help much appreciated!


<Prev in Thread] Current Thread [Next in Thread>