Great answers guys.
I want to dynamically build the variable test and use it as the where part
of the sql query:
so, the first time someone may not have placed a value in availability so I
would want the query to look like:
><cfset test = "where (City LIKE '#city#'
> or State LIKE '#state#')">
But if they chose to place a value in availability but not in state it
would look like this:
><cfset test = "where (City LIKE '#city#'
> or Availability = '#SquareFeet#')">
has anyone done this?
At 08:53 PM 5/17/00 -0400, you wrote:
>Bill,
>
>You don't need the CFSET
>(Is Availability numeric? If so, ditch the single quotes)
>Also, you might put a % after the variable in case somebody abbreviates:
>
>
> <CFQUERY NAME="search" Datasource="sqft">
> SELECT * from property
> WHERE City LIKE '#city#%'
> or State LIKE '#state#%'
> or Availability = '#SquareFeet#'
></CFQUERY>
>
>
>Dave
>
>
>----- Original Message -----
>From: Bill Kaigler <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Wednesday, May 17, 2000 3:44 PM
>Subject: dynamic query
>
>
> > Hi,
> >
> > I am trying something which may not be allowed.
> >
> > <cfset test = "where (City LIKE '#city#'
> > or State LIKE '#state#'
> > or Availability >= '#SquareFeet#')">
> >
> > <CFQUERY NAME="search" Datasource="sqft">
> > Select * from property
> > #test#
> > </CFQUERY>
> >
> > I am getting a 37000 syntax error. I have tried this with and without the
> > single quotes and it gets the same error.
> >
> > I find conditionals in the sql (as shown in both cold fusion books: Danesh
> > and Forta) to be very difficult to maintain as well as read.
> >
> > thanks in advance
> >
> > --------------------------------------------------------------------------
>----
> > Archives: http://www.eGroups.com/list/cf-talk
> > To Unsubscribe visit
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
>send a message to [EMAIL PROTECTED] with 'unsubscribe' in
>the body.
>
>------------------------------------------------------------------------------
>Archives: http://www.eGroups.com/list/cf-talk
>To Unsubscribe visit
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
>send a message to [EMAIL PROTECTED] with 'unsubscribe' in
>the body.
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.