Subquery help

K

K

I think I can do this in one query but I am not sure the verbage. I have the
following scenario:

Lname FName DOS Provider1 Provider2
Smith John 20081212 Jones Williams
Smith John 20081212 Wilson Simpson

What I want to do is find all the records where provider1 = "Jones" and
Provider2 = "Williams" and then with that criteria find all the records that
where lname, fname and DOS are the same. Is this possible in one query?

TIA!

Kim
 
J

John Spencer

Perhaps the following will work for you.

SELECT A.LName, A.FName, A.DOS
FROM [TheTable] as A INNER JOIN [TheTable] As B
ON A.LName = B.LName
AND A.FName = B.FName
AND A.DOS = B.DOS
WHERE B.Provider1 = "Jones" and B.Provider2="Williams"

If the query need to be updatable then you will probably need to use a
correlated subquery to identify the records.

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
K

K

Thanks so much John! This worked liked a charm.

John Spencer said:
Perhaps the following will work for you.

SELECT A.LName, A.FName, A.DOS
FROM [TheTable] as A INNER JOIN [TheTable] As B
ON A.LName = B.LName
AND A.FName = B.FName
AND A.DOS = B.DOS
WHERE B.Provider1 = "Jones" and B.Provider2="Williams"

If the query need to be updatable then you will probably need to use a
correlated subquery to identify the records.

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
I think I can do this in one query but I am not sure the verbage. I have the
following scenario:

Lname FName DOS Provider1 Provider2
Smith John 20081212 Jones Williams
Smith John 20081212 Wilson Simpson

What I want to do is find all the records where provider1 = "Jones" and
Provider2 = "Williams" and then with that criteria find all the records that
where lname, fname and DOS are the same. Is this possible in one query?

TIA!

Kim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top