2014-02-13 54 views
1

我有2個表格,1:1關係。 我試圖從table1和table2中使用PK從table1中選擇一切。從2個表中選擇。 Query = table1 OR table1 + table2

我想選擇table1和IF table1中的所有內容PK = table2 FK THEN(並且只有THEN)從table2中選擇。

爲了簡短起見,我想從table1中選擇即使查詢結果在table2中沒有任何關係。如果有,則從table2中選擇。

任何人都知道如何做到這一點?

+1

查找「左連接」 – charlieparker

+0

感謝的人!有效。 – Notheros

回答

0

這是一個左外連接

select table1.*, table2.* 
from table1 left outer join table2 on table1.PF = table2.PK 
相關問題