Query with 2 <> conditions on different fields not working

natsirtm

Registered User.
Local time
Today, 07:04
Joined
Apr 30, 2007
Messages
57
I'm trying to get this query to return all records except those with category: 4 AND issue: 12

Instead I'm always getting ZERO category: 4 and ZERO issue: 12

Should not the parenthesis force this to be taken as a single "WHERE"?

Code:
SELECT ASSIGNED_TO, COMPLAINT_NUM, DATE_RESOLVED, CATEGORY, ISSUE
FROM tmptbl_tm_YTD
WHERE (CATEGORY<>4 AND ISSUE<>12);
 
Should it not be
SELECT ASSIGNED_TO, COMPLAINT_NUM, DATE_RESOLVED, CATEGORY, ISSUE
FROM tmptbl_tm_YTD
WHERE (CATEGORY=4 AND ISSUE=12);
 
No no, it was meant to exclude rows where category = 4 and issue = 12.

Found a solution. Just used WHERE NOT(category = 4 and issue = 12).

Still don't understand why first didn't work.
 
Oops, did not pay close enough attention

Maybe

WHERE (CATEGORY<>4) AND (ISSUE<>12);
 

Users who are viewing this thread

Back
Top Bottom