markgargan
Programmer
Hey folks,
I have two tables that describe a family
First is person
create person (id integer, name varchar(20));
Second is relationship
create relationship (
relName varchar(16),
fromId integer,
toId integer);
Person
id name
-----------------
1 Dad
2 Mom
3 Mick
4 Jane
Relationship
relname fromId toId
---------------------------------
Husband 1 2
Father 1 3
Father 1 4
Mother 2 3
Mother 2 4
Sibling 3 4
What I'm looking for is some form of sql that will
allow me to create a result set which substitutes the
id's from the relationship table with the names in the person table. i.e. the resultset would look like
Relationship
relname fromId toId
---------------------------------
Husband Dad Mom
Father Dad Mick
Father Dad Jane
Mother Mom Mick
Mother Mom Jane
Sibling Mick Jane
I thought this would be easy to do.
I was wrong.
Any help greatly appreciated.
Thanks,
Mark.
I have two tables that describe a family
First is person
create person (id integer, name varchar(20));
Second is relationship
create relationship (
relName varchar(16),
fromId integer,
toId integer);
Person
id name
-----------------
1 Dad
2 Mom
3 Mick
4 Jane
Relationship
relname fromId toId
---------------------------------
Husband 1 2
Father 1 3
Father 1 4
Mother 2 3
Mother 2 4
Sibling 3 4
What I'm looking for is some form of sql that will
allow me to create a result set which substitutes the
id's from the relationship table with the names in the person table. i.e. the resultset would look like
Relationship
relname fromId toId
---------------------------------
Husband Dad Mom
Father Dad Mick
Father Dad Jane
Mother Mom Mick
Mother Mom Jane
Sibling Mick Jane
I thought this would be easy to do.
I was wrong.
Any help greatly appreciated.
Thanks,
Mark.