0
 tableA     tableB 
IdPrice  price    id   tax   IdPrice 
----------------------  ------------------------------------ 
    4   100    1   20    4 
------------------------  ------------------ ------------------ 
    5   150    2   10    6 
------------------------  ------------------ ------------------ 
    6   270    
------------------------ 
result = 
price id tax 
---- --- ---- 
100  1 20 
150  2 10 
270 null null 
my Query 
SELECT price,id,tax 
FROM tableB INNER JOIN 
tableA ON tableA.IdPrice= tableB.IdPrice 
but this result 

price id tax 
---- --- ---- 
100  1 20 
150  2 10 
+1

將'inner join'更改爲'left join'。請花些時間閱讀http://stackoverflow.com/help/how-to-ask – HoneyBadger

+0

它不是簡單地將內部連接更改爲左連接。 。你需要切換表連接sequnce也 – Squirrel

+0

哈哈,所以把它改爲'右外連接'。然後它不需要切換表連接序列。 – Kason

回答

1
SELECT 
    a.price as price, b.id as id, b.tax as tax 
FROM 
    tableA a 
LEFT OUTER JOIN 
    tableB b ON a.IdPrice = b.IdPrice 

使用左外選擇所有值加入你可以從表A中的所有記錄。