Link to home
Create AccountLog in
Avatar of jazjef
jazjef

asked on

How do I specify a double WHERE statement in SQL?

[I'm Using Visual Web Developer 2008 and SQL Server Express 2008]

I have about 13 fields in a table I want to return-----but only if they contain data (IS NOT NULL)

I need a double WHERE statement; I need to select the records based upon email address and ID# entered into two textboxes....and I only want to return the records where at least one of the specified fields has data (IS NOT NULL)

Here's an abbreviated example of what doesn't work:

Select [field1], [field2], [field3], from TABLE1 WHERE (([Email] = @Email) AND ([IDno] = @IDno)) AND field1 IS NOT NULL, OR field2 IS NOT NULL, OR field3 IS NOT NULL

Something like this ignores the WHERE parameters (email and ID#) and just returns any record from the database that is not null for the specified fields.....any help is appreciated. Thanks.

ASKER CERTIFIED SOLUTION
Avatar of simonpaul64
simonpaul64

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of jazjef
jazjef

ASKER

Duh.

Thanks simonpaul64; that's 500 points for one set of parentheses.

"Stupid is as stupid does"
-----Forrest Gump-----