MySQL学习笔记(一)

2017-06-01  本文已影响0人  leng_feng

多表查询

头一次写文章,写的不好,望宽恕

<p>
多表查询分为:

多表查询一定要注意的是:

多表查询实例:

查询雇员姓名 薪水,部门名称,部门描述 等值连接和内连接

SELECT a.emp_name,a.emp_salary,b.depart_name,b.depart_text from emp a,depart b where a.emp_department=b.depart_name;

SELECT a.emp_name,a.emp_salary,b.depart_name,b.depart_text from emp a INNER JOIN depart b on (a.emp_department=b.depart_name);

id=8雇员的部们名称,部门描述,薪水

SELECT a.emp_name,a.emp_salary,b.depart_name,b.depart_text  from emp a,depart b where a.emp_department=b.depart_name and a.id=8;

雇员姓名,部门,薪水,部门描述,工资级别(三个表)

SELECT a.emp_name,a.emp_department,a.emp_salary,b.depart_text,c.description   from emp a,depart b,sallevel c  where a.emp_department=b.depart_name and a.emp_salary BETWEEN c.min_salary and c.max_salary;
上一篇下一篇

猜你喜欢

热点阅读