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
答案 0 :(得分: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
使用左外连接,您可以从tableA获取所有记录。