>Example of data Actor_1 Actor_2 TR_ID 1 2 1 2 3 2 … Relation_Type: TR_ID (Key) TR_Label
>Example of data TR_ID TR_Label 1 IS_Brother 2 IS_Father ….
It is simple probably so basic for you guys. I would like to extract in a new Table with a query : Actor_1 and Actor_2 and the relation type between them and be able to have the label of Actor_1 and Actor_2 (Actor_label) as well the label for Relation Type (TR_Label). I just managed so far to get the first part of the query, the list of Actor and their type of relationship
With this Query : SELECT Relation_Actor.Actor_1, Relation_Actor.Actor_2, Relation_Actor.TR_ID FROM Relation_Actor;
just miss the way to have the label of Actors and Type of Relationship Thank you in advance SQL Newbie :)
SELECT
a1.Label AS Actor1,
a2.Label AS Actor2,
r.TR_Label AS RelationType
FROM
Relation_Action ra
INNER JOIN Actor a1 ON a1.Actor_ID = ra.Actor_1
INNER JOIN Actor a2 ON a2.Actor_id = ra.Actor_2
INNER JOIN Relation_Type r ON r.TR_ID = ra.TR_ID;
SELECT
a1.Label AS Actor1,
a2.Label AS Actor2,
r.TR_Label AS RelationType
FROM
Relation_Action ra
INNER JOIN Actor a1 ON a1.Actor_ID = ra.Actor_1
INNER JOIN Actor a2 ON a2.Actor_id = ra.Actor_2
INNER JOIN Relation_Type r ON r.TR_ID = ra.TR_ID;