首页 > 数据库 >【MySQL】多表查询:等值连接VS非等值连接

【MySQL】多表查询:等值连接VS非等值连接

时间:2022-08-17 19:45:55浏览次数:62  
标签:多表 等值 连接 department id name

区别:多表查询中的where条件是否相等

1.等值连接

查询员工的employee_id,last_name,department_name,city

SELECT e.last_name,d.department_name,l.city
FROM employees e,departments d,locations l
WHERE e.department_id=d.department_id AND d.location_id=l.location_id;

2.非等值连接

查询员工姓名、工资和等级,工资位于工资表区间内则确定等级

SELECT e.last_name,e.salary,j.grade_level
FROM employees e,job_grades j
WHERE e.salary BETWEEN j.lowest_sal AND j.highest_sal;

image

标签:多表,等值,连接,department,id,name
From: https://www.cnblogs.com/zhishu/p/16596432.html

相关文章