合并 union
1、兩個表列要一致
2、合并時進行了去重操作
select * from test1 union select * from test2;
select id,name from test1 union select id,name from test2;
左右連接
left join? on 兩個表的對應關系--以左表為基準,右邊進行連接
左表中全部展示,坐表中有右表沒有用null補全,左表中沒有右表中有的則刪除
right join? on 兩個表的對應關系--與左表連接相反
select * from test1 right join test2 on test1.id=test2.id;
1、select * from test1 right join test2 on test1.id=test2.id;
(select * from test1 left join test2 on test1.id=test2.id) union (select * from test1 right join test2 on test1.id=test2.id);