Page 130 - SQL
P. 130

SELECT
              T_AccountPlan.AP_UID
             ,T_AccountPlan.AP_Code
             ,T_AccountPlan.AP_Lang_EN
             ,T_BudgetPositions.BUP_Budget
             ,T_BudgetPositions.BUP_UID
             ,T_BudgetPositions.BUP_Jahr
         FROM T_BudgetPositions

         FULL JOIN T_AccountPlan
             ON T_AccountPlan.AP_UID = T_BudgetPositions.BUP_AP_UID
             AND T_AccountPlan.AP_SoftDeleteStatus = 1

         WHERE (1=1)
         AND (T_BudgetPositions.BUP_SoftDeleteStatus = 1 OR T_BudgetPositions.BUP_SoftDeleteStatus IS
         NULL)
         AND (T_AccountPlan.AP_SoftDeleteStatus = 1 OR T_AccountPlan.AP_SoftDeleteStatus IS NULL)



        Recursive JOINs


        Recursive joins are often used to obtain parent-child data. In SQL, they are implemented with
        recursive common table expressions, for example:


         WITH RECURSIVE MyDescendants AS (
             SELECT Name
             FROM People
             WHERE Name = 'John Doe'

             UNION ALL

             SELECT People.Name
             FROM People
             JOIN MyDescendants ON People.Name = MyDescendants.Parent
         )
         SELECT * FROM MyDescendants;



        Differences between inner/outer joins


        SQL has various join types to specify whether (non-)matching rows are included in the result:
        INNER JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN (the INNER and OUTER keywords
        are optional). The figure below underlines the differences between these types of joins: the blue
        area represents the results returned by the join, and the white area represents the results that the
        join will not return.






















        https://riptutorial.com/                                                                             112
   125   126   127   128   129   130   131   132   133   134   135