Select Not Equal query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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);
 
Back
Top