Don't forget--another trick you can use if/when using IF or CASE logic within 
your CFML pages, you can do the following as a trick:

SELECT *
FROM TABLE
WHERE 1=1
<cfif condition 1>
AND CONSTRAINT 1
</cfif>
<cfif condition 2>
AND CONSTRAINT 2
</cfif>
<cfif condition 3>
AND CONSTRAINT 3
</cfif>
<cfif condition 4>
AND CONSTRAINT 4
</cfif>


The benefit of adding the 1=1 is that it always returns true and has no 
negative impact on the query results or performace.  Furthermore, it allows you 
to focus on the conditions in such a way that you do  not have to add addtional 
logic to handle the begining AND in the WHERE clause.

Thomas

>How many use the query coding (where clause) as:
> 
>where
>            x = 1 and
>            Deleted = 0
> 
> 
>OR 
> 
> 
>where 
>        x = 1
>        and Deleted = 0
> 
> 
> 
>I prefer the second one as if I need to remove or simply comment the line
>out for testing, I only do the one line rather than having the comment tags
>skew over multiple lines?
> 
>Thanks for your input. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290457
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to