Join two tables based on relationship defined in third table

前端 未结 3 1647
别那么骄傲
别那么骄傲 2020-12-24 01:36

I have two tables Activity and Action. One or more actions can be performed for an activity. And the relationships between Activity and Action is given in a third table call

3条回答
  •  情话喂你
    2020-12-24 01:51

    SELECT ActivityText AS Activity, ActionText AS ApplicableAction
      FROM Activity 
      JOIN ActivityAction on Activity.ActivityId = ActivityAction.ActivityID
      JOIN Action on Action.ActionId = ActivityAction.ActionID
    

    You have IDs in Action table and when you join table ActivityAction on ActivityId key then you are able to join activity table

提交回复
热议问题