MYSQL查詢的四種情況

來源:互聯網
上載者:User

標籤:rom   欄位   不為   mysql   mysql查詢   from   sel   inner   查詢   

1 普通串連查詢

select 表1欄位1,表2欄位2,from 表1,表2,where 表1.欄位1==表2.欄位2

2 inner join查詢

select 表1欄位1 ,表2欄位2,from 表1 INNER JOIN 表2 ON  表1.欄位1==表2.欄位2

與普通查詢類似

3 LEFT JOIN查詢,左聯查詢

select 表1欄位1 ,表2欄位2,from 表1 LEFT JOIN 表2 ON  表1.欄位1==表2.欄位2

即使右表為空白,也從左表擷取所選取欄位的資料

4 RIGHT JOIN查詢,右聯查詢

select 表1欄位1 ,表2欄位2,from 表1 RIGHT JOIN 表2 ON  表1.欄位1==表2.欄位2

即使左表為空白,也從右表擷取所選取欄位的資料

5 FULL JOIN查詢 ,全聯查詢

select 表1欄位1 ,表2欄位2,from 表1 FULL JOIN 表2 ON  表1.欄位1==表2.欄位2

只要有一個表的欄位不為空白,就返回該條資料

MYSQL查詢的四種情況

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.