-- 创建EMP表
CREATE TABLE EMP
(
EMPNO int(4) PRIMARY KEY,
ENAME VARCHAR(10),
JOB VARCHAR(9),
MGR INT(4),
HIREDATE DATE,
SAL DOUBLE(7,2),
COMM DOUBLE(7,2),
DEPTNO INT(2)
);
-- where查询 语句
SELECT * from emp;
SELECT * FROM DEPT;
SELECT * FROM SALGRADE;
-- where 条件查询
-- 查询员工编号为7000的所有信息
select * from emp where empno=7000;
-- 分别查询薪资大于,小于,不等于1000元员工所有信息
select * from emp where sal>=1000;
select * from emp where sal<=1000;
select * from emp where sal!=1000;
-- <>代表不等于
select * from emp where sal<>1000;
-- 查询入职日期大于1981年的员工信息
select * from emp where HIREDATE>"1981";
SELECT * from emp;
-- and运算符
-- 查询薪资大于1000,并且小于1500元员工的所有信息
select * from emp where sal>=1000 and sal<1500;
select * from emp where sal>=1000 && sal<1500;
-- [500,1600]BETWEEN AND
select * from emp where sal BETWEEN 500 and 1600;
-- 不在该区间信息
select * from emp where sal not BETWEEN 1000 and 1500;
-- or运算符
-- 查询信息小于1500或者大于3000的员工
select * from emp where sal<1000 or sal >1200;
select * from emp where sal<1000 || sal >1200;
-- in,or 查找具体值是否在某范围里
select * from emp where sal in(500,800,300);
SELECT * from emp where sal=500 or sal=300 or sal=800;
-- not in 查找具体值是否在某范围里
select * from emp where sal not in(500,800,300);