View Full Version : SQL "WHERE...Or" question


andreas_udby
12-10-2002, 06:12 PM
If, in a SELECT statement, I have a WHERE clause that specifies "WHERE [conditions A and B] Or [conditions B and C]", does that statement double-count individuals that meet all the conditions A, B, and C?

If so, how would I specifiy it not to include those individuals, so that my statement isn't double-counting them? Is "WHERE [conditions A and B] Or [conditions B and C] NOT [conditions A, B, C]" a legal WHERE clause?

Thanks,
Andreas

Jon K
12-10-2002, 07:38 PM
If (A and B and C) is true, both (A and B) and (B and C) are also true.

The Where Clause is:-
WHERE ((A and B) or (B and C)) and not (A and B and C)


Edit:-
It is always good to have Pat here. My Where Clause would exclude those records where A,B,C are true and include only those records where A,B are true or B,C are true.

Pat Hartman
12-11-2002, 07:07 PM
The where clause is simply selecting which rows should be included in the output recordset. As soon as a row meets the first criteria it is selected, the other criteria are not even evaluated. So the answer is NO, the records are not duplicated.