Jumat, 10 Mei 2013

[MS_AccessPros] Re: filtering to show anyone who has multiple items

 

Try this:

Select Id, Name, Service From TableName Where Service = "Service1"
Union
Select Id, Name, Service From TableName Where Service = "Service2"

--- In MS_Access_Professionals@yahoogroups.com, "Dale C" wrote:
>
> I have Access 2002 and I have a basic query and can't seem to get the
filtering to yield the correct results without creating two queries and
comparing those. Here are the fields I have: ID, Name, Service
> The Service would contain the actual service name such as Service1,
Service2, Service3, Service4, Service5, etc. If someone gets multiple
services then the main table would have that person stored multiple
times, one line for each service they receive. I am trying to make a
query that shows me anyone who is getting Service1 and Service2. If I
use the filter to be "Service1" AND "Service2" it will not display any
results because technically there is no service name that is called
Service1Service2 since each individual service is outputted to a
separate line. If I use the OR statement it does show anyone who has
Service1 or anyone who has Service2 but does not filter to just those
that actually have the Service1 and a line with Service2. How could I
accomplish this? For example, here would be an example of what the query
outputs without a filter:
> 1235 - John - Service1
> 1235 - John - Service3
> 1235 - John - Service2
> 1236 - Jane - Service1
> 1345 - Stan - Service1
> 1345 - Stan - Service2
> 1654 - Jake - Service2
>
> If I wanted those who had service 1 and a service2 it should output
this:
> 1235 - John - Service1
> 1235 - John - Service2
> 1345 - Stan - Service1
> 1345 - Stan - Service2
>

[Non-text portions of this message have been removed]

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar