显式内连接就是使用inner join的办法,写起来复杂些
以windows版本mysql里自带的sakila数据库为例
显式内连接语法 select 字段名 from 表1 join 表2 on 连接条件 [ join 表3 on 连接条件 ... ] [ where 查询条件 ... ];
SELECT store.address_id,first_name,last_name FROM store INNER JOIN staff ON store.manager_staff_id=staff.staff_id;
结果:
address_idfirst_namelast_name
1MikeHillyer
2JonStephens
隐式内连接语法 select 字段名 from 表1,表2 [ ,表3... ] where 连接条件 [ and 查询/连接条件 ... ];
SELECT store.address_id,first_name,last_name FROM store,staff WHERE store.manager_staff_id=staff.staff_id;
结果:
address_idfirst_namelast_name
1MikeHillyer
2JonStephens
相对而言,隐式连接好理解好书写,语法简单,担心的点较少。但是显式连接可以减少字段的扫描,有更快的执行速度。这种速度优势在3张或更多表连接时比较明显