Yep.

<cfif MyCondition>
        <cfquery name="myquery" datasource="mydsn">
                Select * from MyTable
        </cfquery>
</cfif>

OR

<cfquery name="MyQuery" datasource="MyDSN">
        Select * from MyTable
        <cfif MyCondition>
                Where lID = #IDVar#
        </cfif>
</cfquery>

OR

Put the full SQL Statement into a string, using CFIF as needed to build your
string, then like so:

<cfquery name="MyQuery" datasource="MyDSN">
        #MySQLString#
</cfquery>

Hopefully that answers what you were asking.

Shawn Grover

-----Original Message-----
From: LANCASTER, STEVEN M. (JSC-OL) (BAR)
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 12, 2002 2:30 PM
To: CF-Talk
Subject: SQL in a CFIF


How would write a select statement within a CFIF statement.

1. Can it be done?

2. What is the Syntax?

Steven Lancaster
Barrios Technology
NASA/JSC
281-244-2444 (voice)
[EMAIL PROTECTED]

______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to