SQL表串連

來源:互聯網
上載者:User

標籤:style   blog   http   os   資料   width   2014   re   

背景
在上次的自考科目《資料庫系統原理》中,已經接觸到了關於資料庫表串連的一些知識,最近的學習過程中又用到了關於資料庫表的串連問題,趁此再跟大家一起回顧一下。
導圖總結
首先用一張思維導圖概括一下SQL表串連的內容:


對SQL表串連有個大概的瞭解之後,我們通過一個小例子進一步來學習一下。首先,我建立和兩張表:如下



外串連
外串連包括左外串連、右外串連和完整外串連。
左外串連
SQL語句:select * from table1 left join table2 on table1.id=table2.id


右外串連
SQL語句:select * from table1 right join table2 on table1.id=table2.id


完整串連
SQL語句:select * from table1 full join table2 on table1.id=table2.id



內串連
SQL語句:select table1.id,table2.score  from table1 inner join table2 on table1.id=table2.id






交叉串連
SQL語句:select *  from table1 cross join table2 on table1.id=table2.id





其實,學習就是這樣,反反覆複,同時通過在一次次的回顧過程中每次都會有不同的收穫,一點點加深理解。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.