Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

get the rows from two tables whose relation is in 3rd table

/*

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 called Activity Action.

Here is the sql query to perform the action
*/
SELECT Activity.ActivityText as Activity,
 Action.ActionText as ApplicableAction
FROM ActivityAction
    INNER JOIN Activity
        ON ActivityAction.ActivityId = Activity.ActivityId
    INNER JOIN Action 
        ON ActivityAction.ActionId = Action.ActionId
 
PREVIOUS NEXT
Tagged: #rows #tables #relation #table
ADD COMMENT
Topic
Name
8+6 =