Build the whole thing first:
<cfsavecontent variable="myquery">
Select * from contacts where 1
<cfif Form.company IS NOT "All">
and company like '%#Form.company#%'
</cfif>
<cfif Form.city IS NOT "All">
and city like '%#Form.city#%'
</cfif>
<cfif Form.state IS NOT "All">
and state like '%#Form.state#%'
</cfif>
</cfsavecontent>
<cfoutput>#myquery#</cfoutput>
<cfquery name= "GetList" datasource="#DataSource#">
#PreserveSingleQuotes(myquery)#
</cfquery>
> -----Original Message-----
> From: Luis Lebron [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 08, 2003 3:32 PM
> To: CF-Talk
> Subject: Preview a query string
>
>
> I am building a dynamic query that looks like this:
>
> <cfquery name= "GetList" datasource=#DataSource#>
> Select * from contacts where 1
>
> <cfif Form.company IS NOT "All">
> and company like '%#Form.company#%'
> </cfif>
>
> <cfif Form.city IS NOT "All">
> and city like '%#Form.city#%'
> </cfif>
>
> <cfif Form.state IS NOT "All">
> and state like '%#Form.state#%'
> </cfif>
>
> </cfquery>
>
>
> How can I print the actual query string so that I can check
> it's syntax?
>
>
>
> thanks,
>
>
> Luis
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4