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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select difficulties

Status
Not open for further replies.

pondi

Programmer
Jun 6, 2001
32
GB
Here are my 2 tables
ELEMENTS
id
name
type

ELEMENTLINKS
id
n1
n2

n1 and n2 are ids of 2 linked elements. I'd like to display a 2 columns-result:
ELTTYPE1 ELTTYPE2
Note: An Elttype1 is linked to many elttype2 but i'd like to have the full list of dependencies like

elt11 elt21
elt11 elt22
elt12 elt26
elt12 elt27
...

But i can't see how to start the query, like select name, name from elements.????????

Thanx for your help.
 

Hopefully, I've understood the relationship of the tables properly. If not let me know.

Select e1.Type As ELTTYPE1, e2.type As ELTTYPE2
From (ELEMENTLINKS e
Inner Join ELEMENTS e1
On e.n1=e1.id)
Inner Join ELEMENTS e2
On e.n2=e2.id Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
OK thanx, it seems to work with this, i didn't know this kind of use of JOIN.!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top