That's ok, try something like this...

SELECT *
FROM tblBooks
WHERE 1 = 1

<cfif Trim(FORM.authorOne NEQ "">
    AND AuthorOne LIKE '%#FORM.authorOne#%
</cfif>

<cfif Trim(FORM.authorTwo NEQ "">
    AND AuthorTwo LIKE '%#FORM.authorTwo#%'
</cfif>

.....
.....
.....

Or do as you were with building up a where string.

Ade
  -----Original Message-----
  From: Trevor Smith [mailto:[EMAIL PROTECTED]
  Sent: 28 May 2004 22:35
  To: CF-Newbie
  Subject: Re: SQL sytax not jiving with Coldfusion

  Ade,
  Thanks for your time. Sorry, I should have been more specific. I'm not
getting any errors. I want the form to search the first names fields of both
the first and second author (some articles may have two authors). So, I want
the query to first see if it matches either the authorOneFirstName field or
the authorTwoFirstName field, then tack on the rest of the conditions, with
"and"'s. So the problem is this: when you type in, say, "t", for the first
name, it will give you back the record which has Trevor as the
authorOneFirstName, but not the record which has Trevor as the
authorTwoFirstName. Sorry about not being more specific.

  Thanks again,
  Trevor
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to