You need to add parentheses around the (this OR that OR other...).
The priority of boolean operators is that AND is evaluated before OR.
SELECT *
FROM PROVIDERS
WHERE [first name] LIKE '%TOM%'
AND (
srv1 = 'Y' OR srv2 = 'Y' OR srv3='Y'
)
(Ultimately, you will probably have more luck with any sizeable
application if you do not use 14 different Y/N columns. Almost
always, it is a better design to maintain a separate table to record
that information. My suggestion should get you moving forward,
but there is always the risk that it moves you forward closer to the
quicksand.)
Steve Kass
Drew University
George wrote:
Hi all,
I have one table that contains, among other fields, a NAME and 14 SERVICE
fields. The ID number is obvious and the SERVICE fields contain a "Y" if
that particular person (NAME) carries out the service. A person can carry
out 1 or more services or the person can carry no service.
I am trying to write a search screen where the user will enter a partial
name and select 1 or more services to be included. The query will then
return and person who's name is LIKE the entry AND who has at least 1 of the
entered services.
I have the following: "SELECT * FROM PROVIDERS WHERE [first name] LIKE
'%TOM%' AND srv1 = 'Y' OR srv2 = 'Y' OR srv3='Y'.
What I am getting from the above is all people with TOM in their name AND
service 1. I am also getting people - no matter what their name is - with
either service 2 or service 3.
I need all people with TOM in their name and EITHER service 1, service 2 or
service 3.
Re: Pls Help -- Tek-Tip "Running Sum In Queries" ... Would you happen to know of a work-around where I calculate the "Priority"... the user changes data variables in a form. ...Tom... (microsoft.public.access.modulesdaovba)
Re: RORT Charter ...Tom J wrote: ... It may be invalid in your eyes, but it's not in your providers eyes... certainly enough to generate complaints to your provider. ... (rec.outdoors.rv-travel)
Re: Recipient Policies ...Tom,... I'm not changing mailbox stores I'm just reprioritizing ...priority 2 is bumped up to one, ... (microsoft.public.exchange.admin)
Re: Set my own priority ... I will try the Priority class...Tom..."Trev Hunter" wrote in message ... (microsoft.public.dotnet.languages.vb)
Re: Set my own priority ... set the priority for your process (which affects all threads in your ... Most of the time I want to lower it so I don't eat... > I know how to do it with a thread, but how about to myself (so to speak)?... (microsoft.public.dotnet.languages.vb)