nature join

它会帮你自动查询两张连接表中所有相同的字段,然后进行等值连接

  1. SELECT employee_id,last_name,department_name
  2. FROM employees e JOIN departments d
  3. ON e.`department_id` = d.`department_id`
  4. AND e.`manager_id` = d.`manager_id`;
  5. # 等价于
  6. SELECT employee_id,last_name,department_name
  7. FROM employees e natural join departments d;