Looks like you need an IN clause

SELECT
  *
FROM
  MyTable
WHERE
  <cfif MyVar has 1 item>
    MyField = #MyVar#
  <cfelseif MyVar has more than 1 item>
    MyField IN (#MyVar#)
  </cfif>

Does that do it for ya?


Bryan Stevenson
VP & Director of E-Commerce Development
Electric Edge Systems Group Inc.
p. 250.920.8830
e. [EMAIL PROTECTED]
---------------------------------------------------------
Macromedia Associate Partner
www.macromedia.com
---------------------------------------------------------
Vancouver Island ColdFusion Users Group
Founder & Director
www.cfug-vancouverisland.com

----- Original Message -----
From: "LANCASTER, STEVEN M. (JSC-OL) (BAR)" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, March 12, 2002 1:53 PM
Subject: RE: SQL in a CFIF


> Let me give an understanding of what I am doing. I have a variable that is
> passing one or up to three numbers. The numbers are passed like this: 1, 2,
> 3 or 1 or 1,2. My problem is I need to check to see if the the number is
> listed in the #variable#. so That I can go from there. My application works
> as long as my variable is only passing one number. If it passes 2 numbers my
> query doesn't like it. I have a query based on the variable 2 being in
> there. Any help would be appreciated. I am going crazy trying to figure it
> out.
>
> Steven Lancaster
> Barrios Technology
> NASA/JSC
> 281-244-2444 (voice)
> [EMAIL PROTECTED]
>
> -----Original Message-----
> From: Brendan Avery [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 12, 2002 3:43 PM
> To: CF-Talk
> Subject: RE: SQL in a CFIF
>
>
> you can not have your cfif conditional execute on the database-side; but you
> can put cfif and other cftags inside a cfquery tag-pair.  for example if you
> had a page that had to display some item from your database, you could use a
> cfif to decide whether to pull an item by id or if no id is specified, pull
> the default item:
>
> <cfquery name="iteminfo" datasource="mydsn">
> SELECT TOP 1 * FROM tbl_Merchandise
> WHERE
> <cfparam name="currentitem" default="">
> <cfif currentitem IS NOT "">
> id=#currentitem#
> <cfelse>
> default='y'
> </cfif>
> </cfquery>
>
> but it is important to note that the cftags, including the cfif are
> processed before the query itself is sent to the sql server, so all this
> happens within cf.
>
>
>
> > -----Original Message-----
> > From: LANCASTER, STEVEN M. (JSC-OL) (BAR)
> > [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, March 12, 2002 13:30
> > 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]
> >
>
> 
______________________________________________________________________
Get Your Own 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=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to