左連接只影響右表,右鏈接只影響左表。
左連接 (left join)
select * from table1 left join tbale2 on table1.id=table2.id
這條sql語句返回結果
table1表中的數據全部返回 table2表中的數據只返回滿足where條件的
右鏈接 (right join)
select * from table1 right join table2 on table1.id=table2.id
這條sql語句返回結果
table2表中的數據全部返回 table1表中的數據只返回滿足where條件的
(insert join)
select * from table1 inner join table2 on table1.id = table2.id
這條sql語句返回結果 顯示滿足條件的數據 並不以誰為主表