Jump to content


This topic is now archived and is closed to further replies.


Defining Relationships In A Family

Recommended Posts

This is difficult. I wish people just kept to nuclear families where we could have simple relationships but it's more complicated now.

I've got the following tables (simplified of course):

name: family
columns: family_id, familyname

name: child
columns: firstname, lastname, child_id, family_id

name: parent
columns: firstname, lastname, parent_id, family_id

name: relationship
columns: parent_id, child_id, relationship

Now I know how to get the kids out that are not in relationship at all: select * from child, relationship where relationship.child_id <> child.child_id

But that's not what I want to do. I basically want to say, "find all the kids that are related to parent_id X" and then say "now show me all the kids that are not in that list"

Share this post

Link to post
Share on other sites
Shouldn't be a problem... simply issue a LEFT JOIN and search for WHERE child_id IS NULL.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.