Help with a query

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.
 
D

Duane Hookom

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?
 
J

John W. Vinson

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]
 
Top