开发者社区> 问答> 正文

What are different JOINS used in SQL?

What are different JOINS used in SQL?

展开
收起
1780169608831412 2021-10-16 14:23:38 534 0
1 条回答
写回答
取消 提交回答
  • 网络规划设计师、敏捷专家、CISP、ITSS服务经理、ACA全科目、ACP4项、ACE、CBP、CDSP、CZTP等。拥有 PRINCE2 Foundation/Practitioner、CCSK、ITIL、ISO27001、PMP等多项国际认证。 专利5+、期刊10+、知识产权师。核心期刊审稿人。

    4 major types of Joins are used while working on multiple tables in SQL databases:

    INNER JOIN: It is also known as SIMPLE JOIN which returns all rows from BOTH tables when it has at least one matching column.

    Syntax:

    SELECT column_name(s) 
     FROM table_name1 
     INNER JOIN table_name2 
     ON column_name1=column_name2;
    

    LEFT JOIN (LEFT OUTER JOIN): This join returns all rows from the LEFT table and its matched rows from a RIGHT table.

    Syntax:

    SELECT column_name(s)
     FROM table_name1
     LEFT JOIN table_name2
     ON column_name1=column_name2;
    

    RIGHT JOIN (RIGHT OUTER JOIN): This joins returns all rows from the RIGHT table and its matched rows from the LEFT table.

    Syntax:

    SELECT column_name(s)
    FROM table_name1
    RIGHT JOIN table_name2
    ON column_name1=column_name2;
    

    FULL JOIN (FULL OUTER JOIN): This joins returns all results when there is a match either in the RIGHT table or in the LEFT table.

    Syntax:

    SELECT column_name(s)
     FROM table_name1
     FULL OUTER JOIN table_name2
     ON column_name1=column_name2;
    
    2021-10-16 15:17:19
    赞同 1 展开评论 打赏
问答分类:
SQL
问答地址:
问答排行榜
最热
最新

相关电子书

更多
SQL Server在电子商务中的应用与实践 立即下载
GeoMesa on Spark SQL 立即下载
原生SQL on Hadoop引擎- Apache HAWQ 2.x最新技术解密malili 立即下载