I have two tables:
Names
- id (int)
- name (string)
and
Relationships
- id1 (int)
- id2 (int)
I want to query a list of all relationships that have certain id1, and I want to include the names from Names in the resulting query.
So, the result would have four columns
- id1
- id2
- name_for_id1
- name_for_id2
Is this possible? I know I can do an inner join to include one of the names, but I am not sure how to include both names.
For one name I would do something like:
select Relationships.id1, Relationships.id2, Names.name from Relationships
inner join Names
on Names.id1 = Relationships.id1
You can join a table twice.