sql - A query with primary key field used twice -
in database have 2 tables:
relationship table: organization_id_first, organization_id_second, relationship_type
organization table: primary key = org_id ; org_id, org_name, ...
how able join organization
table org_name
both organizations have entry in relationship table? don't think can join on same primary key. have subquery of sort?
thanks!
this how in t-sql ... join twice , make 2 different object
select or1.org_name, or2.org_name, rel.relationship_type relationship rel join organization or1 on rel.organization_id_first = or1.org_id join organization or2 on rel.organization_id_second = or2.org_id
Comments
Post a Comment