sql 表串連基本文法,sql串連基本文法

來源:互聯網
上載者:User

sql 表串連基本文法,sql串連基本文法

SQL串連可以分為內串連、外串連、交叉串連。

1.內串連:內串連查詢操作列出與串連條件匹配的資料行,它使用比較子比較被串連列的列值。

1.1 select * from Table1 as a, Table2 as b where a.id= b.id

1.2 select * from Table1 as a inner join Table2 as b on a.id = b.id

2.3 全串連(當某行在另一個表中沒有匹配行時,則另一個表的挑選清單列包含空值。如果表之間有匹配行,則整個結果集行包含基表的資料值)

select * from Table1 as a full outer join Table2 as b on a.id = b.id

3.左表中的每一行與右表中的所有行組合。交叉聯結也稱作笛卡爾積

select * from Table1 as a cross join Table2 as b order b a.id

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.