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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Query Problems!!!

Status
Not open for further replies.
Aug 4, 2004
84
US
Ideally this query should pull only "non-standard" from fees and only "std" or "none" from offlimits. However this is not the case. I tested this and altered a record in the one table this query is based on. I put "Blah" in the fees and "none" in the offlimits. the query picked it up? Why is the query showing this record??? How would I alter this code? This is driving me crazy.


SELECT [Confirm].[ID], [Confirm].[Fees], [Confirm].[Offlimits], [Confirm].[Office]
FROM Confirm
WHERE [fees]="Non-Standard" and [offlimits]="std" or [offlimits]="none";

thanks,

AB
 
parentheses problem

you have

... WHERE x AND y OR z

because ANDs take precedence over ORs, this is evaluated as

... WHERE ( x AND y ) OR z

what you probably want is

... WHERE x AND ( y OR z )

therefore you have to code the parentheses explicitly

another option is to use IN(list) syntax

... WHERE [fees]='Non-Standard'
and [offlimits] in ('std','none')



rudy
SQL Consulting
 
you probably need to group your conditions:

WHERE [fees]="Non-Standard" and ([offlimits]="std" or [offlimits]="none");


Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top