Hi all,
Well I am still new to sql to getting better and better with each query. Now this one has me completley stumped.

Here is the query

SELECT * FROM MOTORS
WHERE     (CHKCANCEL = '0') AND (DITD IS NULL) AND (CUSTOMERID = '52') OR
                      (CUSTOMERID = '62') OR
                      (CUSTOMERID = '72')

This return 37 rows but there is two rows that have CHKCANCEL = 1

Any Ideas??

Thx

I used this syntax and it work perfectly.

use MTRTRK
SELECT * FROM MOTORS
WHERE CUSTOMERID in ('52', '72', '62') and CHKCANCEL = '0' and DITD IS NULL

the problem with you original query was precedence

what you need is

WHERE (CHKCANCEL = '0') AND (DITD IS NULL) AND( (CUSTOMERID = '52') OR
(CUSTOMERID = '62') OR
(CUSTOMERID = '72'))

Thanks I need to learn the importance of ( and )
THX!!

the problem with you original query was precedence

what you need is

WHERE (CHKCANCEL = '0') AND (DITD IS NULL) AND( (CUSTOMERID = '52') OR
(CUSTOMERID = '62') OR
(CUSTOMERID = '72'))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.