- 查詢每位員工調(diào)整后的薪資(基本工資 +1000)
-- 使用 as 設(shè)置別名
select *,sal+1000 as 調(diào)薪 from emp;
-- 查詢每位員工調(diào)整后的薪資 (基本工資 +1000)
- 使用空格設(shè)置別名
select *,sal+1000 ’調(diào) 薪’ from emp;
-- emp 表中的領(lǐng)導(dǎo)崗位員工
select * from emp where job='manager';
-- 查詢 10 號部門和 20 號部門中 sal低于 2000 的員工信息
select * from emp where (deptno=10 or deptno=20) and sal<2000;
-- 寫法等價,返回相同的結(jié)果
select * from emp where deptno in (10,20) and sal<2000;
-- 查詢基本工資大于或等于 2000 且小于或等于 3000 的員工信息
select * from emp
where sal>=2000 and sal<=3000;
-- 寫法等價,返回相同的結(jié)果
select * from emp where sal between 2000 and 3000;
-- 找出 emp 表中的最高領(lǐng)導(dǎo)人 (沒有更高的上級員工)
select * from emp where mgr is null;
-- 空值與任何值進行運算,都只能返回空值
select * from emp where mgr = null;
-- 查詢姓名不以 a 開頭的員工信息
select * from emp where ename not like 'a%';
-- 查詢姓名中包含 a 的員工信息
Select * from emp where ename like ‘%a%’;
- 查詢姓名中第二個字符為 a 的員工信息
select * from emp where ename like ‘_a%’;
-- 查詢部門 10 的員工信息并按 sal 降序顯示
select *
from emp where deptno = 10 order by sal desc;
-- 查詢所有員工信息并按 deptno 升序、sal 降序顯示
select * from emp order by deptno,sal desc;
-- 查詢基本工資最高的前 5 位員工
select * from emp order by sal desc limit 5;
-- 查詢基本工資從高到低順序第 6 行~第 10 行的員工
select * from emp order by sal desc limit 5,5;
- 根據(jù)職位字母順序排序 emp 表
select * from emp order by job;
-- 只輸出上述結(jié)果的前 4 行
select * from emp order by job limit 0,4;








暫無數(shù)據(jù)