Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL select not giving results wanted

Status
Not open for further replies.

jgeddes

Programmer
Aug 3, 2001
18
US
Here is my select statement:

select STOCK,INVAMT,MAKE,VID,MODEL,ENGINFO,TTYPE,CHAVAIL,PRDCLS,STATUS,EUSER,SLSNO from NDTABLES.CHASSISDB WHERE MAKE='MACK' OR MAKE='VOLVO' AND PRDCLS='RO' ORDER BY STOCK

Currently, it gives me only MACK and VOLVO, but I get any and all records for PRDCLS.??!?!?!

Why?

Thanks...

John
 
You are probably having a problem with the precedence of AND over OR. Try using parentheses:

select STOCK,INVAMT,MAKE,VID,MODEL,ENGINFO,TTYPE,CHAVAIL,PRDCLS,STATUS,EUSER,SLSNO from NDTABLES.CHASSISDB WHERE (MAKE='MACK' OR MAKE='VOLVO') AND PRDCLS='RO' ORDER BY STOCK
 
karluk

That would work, but I guess what I did not explain fully is I am using SQL inside another application and I am letting the user select predicates dynamically.

I did get it to work perfectly using IN instead of =.


Thanks for the help.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top