teachers

mysql多表查询

对着背影说爱祢 提交于 2020-01-23 20:29:07
文章目录 union, union all cross join inner join left [outer] join right [outer] join 自连接 三张表内连接 子查询 union, union all -- 第一张表与第二张表纵向地合并,有去重的功能 MariaDB [ hellodb ] > select * from teachers - > union - > select stuid,name,age,gender from students ; MariaDB [ hellodb ] > select * from teachers union select * from teachers ; -- 纵向合并不去重 MariaDB [ hellodb ] > select * from teachers union all select * from teachers ; cross join -- 交叉连接 ( 横向笛卡尔 ) MariaDB [ hellodb ] > select * from students cross join select * from teachers ; inner join MariaDB [ hellodb ] > select * from students inner join teachers on