select * from table1,table2; 笛卡尔积查询
select * from table1,table2 where table1.column_name = table1.column_name; 条件查询
外连接操作:
内连接 : 符合条件查询 只链接匹配的行
select * from table1 inner join table2 on table1.column_name=table2.column_name; # inner join 关键字查询 结果同上
左链接: 优先显示左表记录
select * from table1 left join table2 on table1.column_name=table2.column_name;
右链接:优先显示右表记录
select * from table1 right join table2 on table1.column_name=table2.column_name;
全外连接:
select * from table1 left join table2 on table1.column_name=table2.column_name
union
select * from table1 right join table2 on table1.column_name=table2.column_name;