Good Methods or Tutorials for Understanding JOINs in SQL

As we know, there are different types of JOINs in any DBMS, for example: - Left join, outer join, inner join, left outer join, etc. Invariably, we use JOIN for many of our business logic in our projects. However, very few people have full understanding or mastery of these JOINS. Usually people with semi-known knowledge of JOINs tend to get confused with complex queries. My area of ​​interest will be mainly related to SQL Server, since we use it in almost all of our projects.

I have read some good articles about JOINs, but most of them are more confusing than convincing. So I wanted to know if there are good ways / methods or any good tutorials for a good understanding of SQL JOINs. The tutorials should be simple enough and also help strengthen our foundations for JOINs.

Thanks in advance.

+3
source share
5 answers

I find this link, visually displaying various connections on Venn diagrams , quite concise.

... Left join, outer join, inner join, left outer join ...

LEFT JOIN LEFT OUTER JOIN ; OUTER.

+9

, , , .

, . , , .

, , (: leftTable left join rightTable) , , , , , .

- , , , , , .

, null - , . (leftTable | bothTables | rightTable).

+2

, . , . ( > 13 000 ), .

+1

, : SQL Microsoft SQL Server 2008 T-SQL . , ( ) , SQL Server . , . , ( !): http://blog.sqlauthority.com/2009/04/06/sql-server-logical-query-processing-phases-order-of-statement-execution/

+1

, .

:

SELECT Col1, Col2
FROM
    Customer AS C

        INNER JOIN
    Order AS O
        ON C.CustomerID = O.CustomerID

        INNER JOIN
    OrderItem AS OI
        ON O.OrderID = OI.OrderID

        LEFT JOIN
    OrderSomething OS
        ON C.CustomerID = OS.CustomerID
           AND O.OrderID = OS.OrderID

, , , , ON .

, , . , , , , .

0

Source: https://habr.com/ru/post/1771356/


All Articles