SQL between查询 范围查询

--sal为员工工资

select * from emp;

 

 

--查询工资在[1500,3000]范围的员工信息

select * from emp where sal >= 1500 and sal <= 3000;

select * from emp where sal between 1500 and 3000;

--上面两句效果一样

 

 

--查询工资小于1500或者大于3000的员工信息

select * from emp where sal < 1500 or 3000 < sal;

select * from emp where sal not between 1500 and 3000;

--上面两句效果一样

 

--查询工资为3000员工信息

select * from emp where sal = 3000;

你可能感兴趣的:(sql)