首页 > 数据库技术 > 详细

0603mysql数据增删改查练习

时间:2018-06-03 18:36:07      阅读:219      评论:0      收藏:0      [点我收藏+]

技术分享图片

1. 查询出部门编号为30的所有员工

select * from yg where deptno = 30;
2. 所有销售员的姓名、编号和部门编号。 

select ename,empno,deptno from yg where job = "销售员";
3. 找出奖金高于工资的员工。

select * from yg where comm > sal;
4. 找出奖金高于工资60%的员工。

select * from yg where comm > 0.6*sal;
5. 找出部门编号为10中所有经理,和部门编号为20中所有销售员的详细资料。

select * from yg where (deptno = 10 and job = "经理")or(deptno = 20 and job = "销售员");

6.找出部门编号为10中所有经理,部门编号为20中所有销售员,还有即不是经理又不是销售员但其工资大或等于20000的所有员工详细资料。

select * from yg where (deptno = 10 and job = "经理")or(deptno = 20 and job = "销售员")or(job not in("经理","销售员") and sal >= 20000);

7.无奖金或奖金低于1000的员工。

select * from yg where comm <= 1000 or comm is null;
8. 查询名字由三个字组成的员工。

select * from yg where ename like "___";
9.查询2000年入职的员工。

select * from yg where hiredate like "2000%";

select * from yg where hiredate >= "2000-01-01" and hiredate <= "2000-12-31";
10. 查询所有员工详细信息,用编号升序排序

select * from yg order by empno asc;
11. 查询所有员工详细信息,用工资降序排序,如果工资相同使用入职日期升序排序

select * from yg order by sal desc,hiredate asc;

12.查询姓周的两个名字的员工。

select * from yg where ename like "_";

查询所有姓张的员工。

select * from yg where ename like "%";

 

0603mysql数据增删改查练习

原文:https://www.cnblogs.com/zhangbaozhong/p/9129892.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!