Answered
Ignoring Rows with Empty Fields?
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!
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!
