this has to be where (0 != 0) otherwise you will get the entire table if both
name and id are NOT defined

"Dave Hannum" <[EMAIL PROTECTED]> wrote:
You have to account for the fact that one or both or neither may be there:
One way would be:

select *
from tbl
where 0 = 0
<cfif isdefined("id")>
or id = #id#
</cfif>
<cfif isdefined("name")>
or name = '#name#'
</cfif>

  The WHERE 0 = 0 simply is a dummy conditional that will keep you from
crashing if neither variable is present and allows you to  use the or
statement with both cases.  (Don't forget the single ticks around your name
field - text you know)

Dave


=================================
"What we need is a list of specific unknown problems we will encounter"

David Hannum
Web Analyst/Programmer
Ohio University
[EMAIL PROTECTED]
(740) 597-2524



----- Original Message -----
From: "Dan Donnick" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, September 28, 2000 12:35 PM
Subject: conditional where statement


is this correct or am i missing something?

select *
from tbl
where <cfif isdefined(")>
id = #id#
</cfif>
or
<cfif isdefined(")>
name = #name#
</cfif>
______________________________

Dan Donnick
Cold Fusion Developer
Bixler Incorporated
1250 24th Street
Suite 250
Washington, DC 20037
P: (202) 686-5800
F: (202) 686-5801
______________________________

----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
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.mail-archive.com/[email protected]/
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.


____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebarRsts&bodyRsts/cf_talk or send a message 
to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to