SQL基础(一四)--- 反义运算符

来源:互联网 发布:子宫b超单数据怎么看 编辑:程序博客网 时间:2024/04/29 10:41

查询年龄不等于22,并且工资不小于2000的员工信息:

方式一
mysql> select * from t_employee    -> where fage<>22 and fsalary>=2000;+----------+-------+------+---------+| fnumber  | fname | fage | fsalary |+----------+-------+------+---------+| DEV001   | Tom   |   25 | 8300    || DEV002   | Jerry |   28 | 2300.8  || HR001    | Jane  |   23 | 2200.88 || HR002    | Tina  |   25 | 5200.36 || IT001    | Smith |   28 | 3900    || IT002    | NULL  |   27 | 2800    || SALES001 | John  |   23 | 5000    || SALES002 | Kerry |   28 | 6200    |+----------+-------+------+---------+8 rows in set
方式二
mysql> select * from t_employee    -> where fage!=22 and fsalary>=2000;+----------+-------+------+---------+| fnumber  | fname | fage | fsalary |+----------+-------+------+---------+| DEV001   | Tom   |   25 | 8300    || DEV002   | Jerry |   28 | 2300.8  || HR001    | Jane  |   23 | 2200.88 || HR002    | Tina  |   25 | 5200.36 || IT001    | Smith |   28 | 3900    || IT002    | NULL  |   27 | 2800    || SALES001 | John  |   23 | 5000    || SALES002 | Kerry |   28 | 6200    |+----------+-------+------+---------+8 rows in set
方式三
mysql> select * from t_employee    -> where not(fage=22) and not(fsalary<2000);+----------+-------+------+---------+| fnumber  | fname | fage | fsalary |+----------+-------+------+---------+| DEV001   | Tom   |   25 | 8300    || DEV002   | Jerry |   28 | 2300.8  || HR001    | Jane  |   23 | 2200.88 || HR002    | Tina  |   25 | 5200.36 || IT001    | Smith |   28 | 3900    || IT002    | NULL  |   27 | 2800    || SALES001 | John  |   23 | 5000    || SALES002 | Kerry |   28 | 6200    |+----------+-------+------+---------+8 rows in set




0 0
原创粉丝点击