simple OR sql will not work as examples show

R

Rocky

I'm trying to simply display all records with the EndMinute field value of
0 or 15 or30 or 45

When I use the following code...

SELECT Cust.[Case #], Cust.Client, Cust.Server, Cust.[Service Code],
Cust.[Service Desc], Cust.[End Minute]
FROM Cust
WHERE Cust.[Case #] Is Not Null AND Cust.[End Minute]<>0;

I get the expected results of a few records with End Minute of 15, 30 or 45

I should be able to change the WHERE statement to...
WHERE Cust.[Case #] Is Not Null AND Cust.[End Minute]<>0<>15<>30<>45;

The result is ALL records show up again. If I even try <>0<>15 it displays
all records.

I believe I'm doing exactly what examples show i.e. www.w3schools.com example
SELECT * FROM Persons WHERE
LastName='Svendson'
AND (FirstName='Tove' OR FirstName='Ola')

Thanks if anyone can help
 
R

Rocky

Sorry guys, I meant to explain that I'm trying to bring back all records
which do not meet the criteria 0 or 15 or 30 or 45... rest of the info is
good though.
 
S

Sylvain Lafontaine

First, you should always post the (invalid) query exactly as you have wrote
it; otherwise we have to guess on what might be going wrong. In your case,
probably that you want to use the AND instead of the OR:

WHERE Cust.[Case #] Is Not Null AND Cust.[End Minute]<>0 AND Cust.[End
Minute]<>15 AND Cust.[End Minute]<>30 AND Cust.[End Minute]<>45;

Using NOT IN could also be a good idea:

WHERE Cust.[Case #] Is Not Null AND Cust.[End Minute] Not IN (0,15,30,45);

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)
 
R

Rocky

YOU ROCK Sylvain !!!! .... it works yaaaahhhOOOOOO

--
Rocky''''''''s Curious Coding


Sylvain Lafontaine said:
First, you should always post the (invalid) query exactly as you have wrote
it; otherwise we have to guess on what might be going wrong. In your case,
probably that you want to use the AND instead of the OR:

WHERE Cust.[Case #] Is Not Null AND Cust.[End Minute]<>0 AND Cust.[End
Minute]<>15 AND Cust.[End Minute]<>30 AND Cust.[End Minute]<>45;

Using NOT IN could also be a good idea:

WHERE Cust.[Case #] Is Not Null AND Cust.[End Minute] Not IN (0,15,30,45);

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)


Rocky said:
I'm trying to simply display all records with the EndMinute field value of
0 or 15 or30 or 45

When I use the following code...

SELECT Cust.[Case #], Cust.Client, Cust.Server, Cust.[Service Code],
Cust.[Service Desc], Cust.[End Minute]
FROM Cust
WHERE Cust.[Case #] Is Not Null AND Cust.[End Minute]<>0;

I get the expected results of a few records with End Minute of 15, 30 or
45

I should be able to change the WHERE statement to...
WHERE Cust.[Case #] Is Not Null AND Cust.[End Minute]<>0<>15<>30<>45;

The result is ALL records show up again. If I even try <>0<>15 it displays
all records.

I believe I'm doing exactly what examples show i.e. www.w3schools.com
example
SELECT * FROM Persons WHERE
LastName='Svendson'
AND (FirstName='Tove' OR FirstName='Ola')

Thanks if anyone can help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top