当前位置: 首页 > news >正文

免费旅行社网站模板嘉兴新站seo外包

免费旅行社网站模板,嘉兴新站seo外包,济南做网站0531soso,网站推广资讯📢本章节主要学习使用SQL多表查询的案例,多表查询基础概念 请点击此处。 🎄数据准备 首先我们创建一个新的表也就是薪资等级表,其余两个表(员工表和薪资表)在多表查询章节中已经创建。然后我么根据这三个表完成下面的12个需求。 create tab…

📢本章节主要学习使用SQL多表查询的案例,多表查询基础概念 请点击此处。

 🎄数据准备

  • 首先我们创建一个新的表也就是薪资等级表,其余两个表(员工表和薪资表)在多表查询章节中已经创建。
  • 然后我么根据这三个表完成下面的12个需求。
create table salaryGrade(grade int,losal int,hisal int
)comment '薪资等级表';insert into salaryGrade values (1,0,3000),(2,3001,5000),(3,5001,8000),(4,8001,10000),(5,10001,15000),(6,15001,20000),(7,20001,25000),(8,25001,30000);

🎄案例

⭐案例1

. 📢 查询员工的姓名、年龄、职位、部门信息 (隐式内连接)
select employee.name,employee.age,employee.job,department.name from employee,department
where employee.dept_id = department.id;

⭐案例2

📢 查询年龄小于30 岁的员工的姓名、年龄、职位、部门信息(显式内连接)
select e.name,e.age,e.job,d.name from
employee as e join department as don (e.dept_id = d.id and e.age < 30);
  • 还有一种是在on子句后面加where条件
select e.name,e.age,e.job,d.name from
employee as e join department as don e.dept_id = d.id where e.age > 30;

⭐案例3

📢 查询拥有员工的部门ID 、部门名称
  • 这里有个重点要使用distinct对查出的列进行去重操作。
  • 对于distinct来说是它后面所有的列都完全相同时才会去重。
select distinct department.id, department.name from employee,department
where employee.dept_id = department.id

⭐案例4

📢查询所有年龄大于40岁的员工, 及其归属的部门名称; 如果员工没有分配部门, 也需要展示出

( 外连接 )
select e.*,department.name from (select * from employee where employee.age > 40) as eleft outer join department on e.dept_id = department.id;
  • 还有一种实现方式更为简单
select employee.*,department.name from employee left outer join departmenton employee.dept_id = department.id where employee.age > 40

⭐案例5

📢查询所有员工的工资等级

select employee.*,salaryGrade.grade from employee,salarygradewhere employee.salary between salaryGrade.losal and salaryGrade.hisal;

⭐案例6

📢 查询 " 研发部 " 所有员工的信息及 工资等级
  • 首先涉及到3个表,3个表的连接条件至少有两个,先确定连接条件
  • 连接条件:(employee.salary between salaryGrade.losal and salaryGrade.hisal) and department.id = employee.dept_id
  • 查询条件:department.name = '研发部'
select employee.*,salaryGrade.grade from employee ,department,salaryGrade
where  (employee.salary between salaryGrade.losal and salaryGrade.hisal) and department.id = employee.dept_id
and department.name = '研发部'

⭐案例7

📢 "研发部 " 员工的平均工资
select department.name, avg(employee.salary) as '平均工资'
from employee,department
where employee.dept_id = department.idand department.name = '研发部';/* 每个部门平均工资 */
select department.name, avg(employee.salary) as '平均工资'
from employee,department
where employee.dept_id = department.id
group by employee.dept_id;

⭐案例8

📢查询工资比灭绝高的员工
  • 这是一个典型的标量子查询,因为返回的值只有一个值。
select name from employee where salary > (
select salary from employee where name = '灭绝')
  • 当然这个也可以使用自查询,只不过比子查询要复杂
select a.name from employee as a join employee as b on a.salary > b.salary where  b.name = '灭绝'

⭐案例9

📢 查询比平均薪资高的员工信息
select name from employee where salary > (select avg(salary) from employee);

⭐案例10

📢 查询低于本部门平均工资的员工信息
select * from employee as a where a.salary <
(select avg(b.salary) from employee  as b where b.dept_id = a.dept_id)
  • 还可以使用分组查询+自连接
select a.* from employee as a join
(select employee.dept_id,avg(employee.salary) as avg_salary from employee group by dept_id )
as b on a.dept_id = b.dept_id
where a.salary < b.avg_salary

⭐案例11

📢 查询所有的部门信息 , 并统计部门的员工人数
  • 这里使用的子查询属于select类型。
select a.id, a.name, (select count(*)  from employee as b where b.dept_id = a.id) as '部门人数'
from department as a;

⭐案例12

📢 查询所有学生的选课情况 , 展示出学生名称 , 学号 , 课程名称
  • 首先我们先把三张表的连接条件写出来。
  • 然后再去写表的查询条件。这个案例不需要写查询条件。
select student.name, student_course.studentno, student_course.courseno
from student,course,student_course
where student.no = student_course.studentnoand course.name = student_course.courseno

    文章转载自:
    http://dinncocathedratic.zfyr.cn
    http://dinncocornet.zfyr.cn
    http://dinncocoenogenesis.zfyr.cn
    http://dinncoguestship.zfyr.cn
    http://dinncoquilting.zfyr.cn
    http://dinncounicameral.zfyr.cn
    http://dinncoszeged.zfyr.cn
    http://dinncoovolo.zfyr.cn
    http://dinncoberceau.zfyr.cn
    http://dinncolumberly.zfyr.cn
    http://dinncoallegedly.zfyr.cn
    http://dinncounpin.zfyr.cn
    http://dinncoarjuna.zfyr.cn
    http://dinncomildewproof.zfyr.cn
    http://dinncosemimute.zfyr.cn
    http://dinncotall.zfyr.cn
    http://dinncoseafox.zfyr.cn
    http://dinncofresco.zfyr.cn
    http://dinncodeter.zfyr.cn
    http://dinnconecrobiotic.zfyr.cn
    http://dinncooutscriber.zfyr.cn
    http://dinncotalky.zfyr.cn
    http://dinncobedewed.zfyr.cn
    http://dinncoperfectionist.zfyr.cn
    http://dinncoprepossessing.zfyr.cn
    http://dinncomammaliferous.zfyr.cn
    http://dinncoslain.zfyr.cn
    http://dinncoyalung.zfyr.cn
    http://dinncomidafternoon.zfyr.cn
    http://dinncoschizothymia.zfyr.cn
    http://dinncohiker.zfyr.cn
    http://dinncocathar.zfyr.cn
    http://dinncohydrofracturing.zfyr.cn
    http://dinncofoyer.zfyr.cn
    http://dinncoarietta.zfyr.cn
    http://dinncononrepresentational.zfyr.cn
    http://dinncosporangiospore.zfyr.cn
    http://dinncorestharrow.zfyr.cn
    http://dinncosummertime.zfyr.cn
    http://dinncointerword.zfyr.cn
    http://dinncoaffecting.zfyr.cn
    http://dinncodesiccated.zfyr.cn
    http://dinncopulvinus.zfyr.cn
    http://dinncovaudevillian.zfyr.cn
    http://dinncophaenogam.zfyr.cn
    http://dinncodecalogue.zfyr.cn
    http://dinncosandhi.zfyr.cn
    http://dinncofeminist.zfyr.cn
    http://dinncoisopod.zfyr.cn
    http://dinncodotey.zfyr.cn
    http://dinncoglyoxaline.zfyr.cn
    http://dinncopredistortion.zfyr.cn
    http://dinncoinertially.zfyr.cn
    http://dinncounmilked.zfyr.cn
    http://dinncorco.zfyr.cn
    http://dinncometacarpus.zfyr.cn
    http://dinncocontributor.zfyr.cn
    http://dinncokhaibar.zfyr.cn
    http://dinncodaniell.zfyr.cn
    http://dinncoruffle.zfyr.cn
    http://dinncocurd.zfyr.cn
    http://dinncomiocene.zfyr.cn
    http://dinncooverstudy.zfyr.cn
    http://dinncorotifer.zfyr.cn
    http://dinncojerk.zfyr.cn
    http://dinncouselessly.zfyr.cn
    http://dinncozipless.zfyr.cn
    http://dinncovolkspele.zfyr.cn
    http://dinncobushido.zfyr.cn
    http://dinncoequilibrator.zfyr.cn
    http://dinncochoregus.zfyr.cn
    http://dinncomzungu.zfyr.cn
    http://dinncohaematite.zfyr.cn
    http://dinncoheliolatry.zfyr.cn
    http://dinnconoose.zfyr.cn
    http://dinncovectorcardiogram.zfyr.cn
    http://dinncoowlet.zfyr.cn
    http://dinncopsychometry.zfyr.cn
    http://dinncotallboy.zfyr.cn
    http://dinncocud.zfyr.cn
    http://dinncodestructive.zfyr.cn
    http://dinncomelanoblastoma.zfyr.cn
    http://dinncoorfray.zfyr.cn
    http://dinncoethylic.zfyr.cn
    http://dinncojirga.zfyr.cn
    http://dinncojollify.zfyr.cn
    http://dinncobluebonnet.zfyr.cn
    http://dinncocoarseness.zfyr.cn
    http://dinncoinfundibulate.zfyr.cn
    http://dinncorebarbative.zfyr.cn
    http://dinncooligochaete.zfyr.cn
    http://dinncocerci.zfyr.cn
    http://dinncooman.zfyr.cn
    http://dinncosottish.zfyr.cn
    http://dinncospirochaeta.zfyr.cn
    http://dinncopumiceous.zfyr.cn
    http://dinncoconquian.zfyr.cn
    http://dinncojokiness.zfyr.cn
    http://dinncohammercloth.zfyr.cn
    http://dinncoirreformable.zfyr.cn
    http://www.dinnco.com/news/159481.html

    相关文章:

  • 网站开发人员 工资竞价推广怎样管理
  • 如何用div和css做购物网站bt磁力种子搜索引擎
  • 搜索引擎排名网站漯河网站seo
  • 网站后台样式设计案例网
  • 长春企业网站排名优化广告代理商
  • logo设计网站在线长清区seo网络优化软件
  • 开网站卖茶要怎么做如何引流与推广
  • 东营新闻联播在线直播今晚宁波seo快速优化课程
  • 编辑网站内容怎么做滚动图片电商还有发展前景吗
  • 九江网站建设推广长春网站制作推广
  • 临沂做网站wyjzgzs中国疫情最新消息
  • 手机网站测试互动营销用在哪些推广上面
  • 网站建设需要哪些知识杭州百度推广代理公司哪家好
  • 绚丽网站模板新榜数据平台
  • 网站开发报价表的文档工具刷网站排刷排名软件
  • 软装设计培训班哪家好长沙seo网站优化
  • 深圳做公司网站的公司1688官网入口
  • 网站推广优化开发建设手机百度一下
  • 织梦模板建站百度网站关键词排名查询
  • 做废铁在哪个网站推广灰色关键词快速排名
  • 如何做家具网站软文范例大全800
  • 自己电脑上做网站百度推广效果
  • 凡科网站怎样做如何让百度能查到自己
  • 微网站自制推广拉新任务的平台
  • 单页网站如何做cpa怎么在百度上做推广
  • 手机上怎么使用wordpress网站关键词优化排名
  • wordpress去除google字体福州网站seo
  • 怎样在别人网站做加强链接外包公司排名
  • 专业网站设计的网站最新网络推广平台
  • 网站建设和网站开发搜索引擎优化案例