Help with a query

  • Thread starter Thread starter scottpconnors
  • Start date Start date
S

scottpconnors

First of all thank you for taking the time to read my question. I am
having a problem running a query on a simple table. Trying to run a
query on a table with a field called ENCOUNTERS and a field called
CODES. What I'm trying to ask get out of the query is this: Every time
an ENCOUNTERS field has a CODES value of 69210, I want it to return
all other CODES results for that ENCOUNTERS number.
 
I can't make any sense of your question. I'm not sure how one field can have
another field value. Why 69210?

Can you provide some table and field names, data types, and possibly some
sample records?
 
First of all thank you for taking the time to read my question. I am
having a problem running a query on a simple table. Trying to run a
query on a table with a field called ENCOUNTERS and a field called
CODES. What I'm trying to ask get out of the query is this: Every time
an ENCOUNTERS field has a CODES value of 69210, I want it to return
all other CODES results for that ENCOUNTERS number.

A "Self Join" query should do this. I'm guessing the table is named MyTable.
The SQL of the query would be

SELECT B.ENCOUNTERS, B.CODES
FROM mytable AS A
INNER JOIN mytable AS B
ON A.ENCOUNTERS = B.ENCOUNTERS
WHERE A.CODES = 69210;

Copy and paste this into the SQL window of a new query and see if it gets you
the desired result.

John W. Vinson [MVP]
 

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

Back
Top