Select Not Equal query

S

Samantha

I want to create a query that's NOT equal to 9 or 12, but is not working.
Here is what I have so far:

SELECT [num], [serial], [id]
FROM [DETAIL]
WHERE ([serial]="5401") AND ([ID]<>9 OR [ID]<>12);

I'm getting a result where ID=12 shows up. Can anyone help with this? thank
you in advance.
 
M

Marshall Barton

Samantha said:
I want to create a query that's NOT equal to 9 or 12, but is not working.
Here is what I have so far:

SELECT [num], [serial], [id]
FROM [DETAIL]
WHERE ([serial]="5401") AND ([ID]<>9 OR [ID]<>12);

I'm getting a result where ID=12 shows up. Can anyone help with this? thank
you in advance.


Change the OR to AND
 
J

John Spencer

Try one of the following variants (all should work)

SELECT [num], [serial], [id]
FROM [DETAIL]
WHERE ([serial]="5401") AND ([ID]<>9 AND [ID]<>12);


SELECT [num], [serial], [id]
FROM [DETAIL]
WHERE [serial]="5401" AND [ID] Not In (9,12);



SELECT [num], [serial], [id]
FROM [DETAIL]
WHERE ([serial]="5401") AND Not ([ID]=9 OR [ID]=12);
 
Top