Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Question

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Thanks in advance for your time.

I'm trying to find related records in one table that are linked together, much like a linked list.

table name: t_data
fields: output_id, PK autonumber
input_id, FK to output_id same table

Any previous output_id can become the input_id for a new record. I would like to be able to find or group records that are linked together, from the first record in a chain to the last. Remember these are all in the same table.

i.e. output_id input_id

13 6
14 7
15 13
16 7
17 15
18 16

I would like to see the recordset showing:

output_id input_id

13 6
15 13
17 15
18 16

Thanks very much


Andre
 
Hi digital_dude,

The following query will solve u r problem

SELECT tdata.output_id, t_data.output_id
FROM t_data AS tdata INNER JOIN t_data ON tdata.input_id = t_data.output_id;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top