i need to write an SQL statement that will have 4 fields and 4 parameters
now the parameter may or may not have values and the fields them-self may or
may not have values

this is what i have so far
SELECT field1, field2, field3, field4
FROM theTable
WHERE (field1 = P1 or P1 IS NULL AND field1 IS NULL) AND
(field2 = P2 or P2 IS NULL AND field2 IS NULL) AND
(field3 = P3 or P3 IS NULL AND field3 IS NULL) AND
(field4 = P4 or P4 IS NULL AND field4 IS NULL)

p1 dose not have a value
p2 = 'A'
p3 = 'c'
p4 dose not have a value


--
Darren Spooner, EMT-B
Darren@spoonerusa.net
U.S. Space & Rocket Center
Shipping & Receiving Clerk & Developer
DarrenS@spacecamp.com
HEMSI Urban Responder
Unit 323

Re: HELP by Jon

Jon
Fri Oct 22 02:14:09 CDT 2004

Darren Spooner <DarrenS@ihatespam.spacecamp.com> wrote:
> i need to write an SQL statement that will have 4 fields and 4 parameters
> now the parameter may or may not have values and the fields them-self may or
> may not have values
>
> this is what i have so far
> SELECT field1, field2, field3, field4
> FROM theTable
> WHERE (field1 = P1 or P1 IS NULL AND field1 IS NULL) AND
> (field2 = P2 or P2 IS NULL AND field2 IS NULL) AND
> (field3 = P3 or P3 IS NULL AND field3 IS NULL) AND
> (field4 = P4 or P4 IS NULL AND field4 IS NULL)
>
> p1 dose not have a value
> p2 = 'A'
> p3 = 'c'
> p4 dose not have a value

Okay, and what's your question? The above (potentially with changes of
how you declare the parameters, depending on your provider) looks
basically okay.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too