HELP

  • Thread starter Thread starter Darren Spooner
  • Start date Start date
D

Darren Spooner

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
(e-mail address removed)
U.S. Space & Rocket Center
Shipping & Receiving Clerk & Developer
(e-mail address removed)
HEMSI Urban Responder
Unit 323
 
Darren Spooner said:
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.
 
Back
Top