在MySQL数据库中,有多种方法有都可以实现多表联查。
下面介绍两种常见的实现MySQL多表联查的方法。
MySQL多表联查的简单方法:
1 2 3 4 |
select c.column, e.column from tablec c, tablea a, tableb b, tablesa sa, tables s, tablee e where c.consultant_id=a.consultant_id and a.besoin_id=b.besoin_id and b.salarie_id=sa.salarie_id and ssa.site_id=s.site_id and s.entreprise_id=e.entreprise_id |
MySQL多表联查的inner join方法:
1 2 3 4 5 6 7 |
select c.column, e.column from tablec c inner join tablea a on c.consultant_id=a.consultant_id inner join tableb b on a.besoin_id=b.besoin_id inner join tablesa sa on b.salarie_id=sa.salarie_id inner join tables s on ssa.site_id=s.site_id inner join tablee e on s.entreprise_id=e.entreprise_id |