1、> 

2、<

3、>=

4、<=

5、<>:不等于

6、between A and B:查询位于A和B区间(闭区间)的数据且必须遵循左小右大的原则,除了可以使用在数据方面,还可以使用在字符方面(但是左闭右开)

7、is null:查看某个字段为null的数据项,select * from tablename where bonus  is null ,不能写成select * from tablename where bonus  =  null 

8、and / or:两者联用时,and的优先级大于or优先级,or语句一般要括起来,括起来的优先级更高最先执行

数据库操作运算符

 

9、in / not in

数据库操作运算符

 

 

 

10、like:模糊查询,必须掌握的两种符号 " % "  和 " _ " ,''%":代表多个字符,"_":代表一个字符。

数据库操作运算符  数据库操作运算符

 

 

 

 11、排序(升序/降序):默认是升序,asc:升序 / desc:降序

数据库操作运算符  数据库操作运算符

 

 

 

12、分组函数:count,sum,avg,max,min,分组函数会自动忽略null,即不会统计为null的数据项.注意:不管任何数据库,只要有null进行算数运算,就会产生null的结果值

  select count(*)  from tablename ;

  select sum(salary)  from tablename ;

  select max(age)  from tablename ;

  select avg(salary) from tablename;

count(*):对数据条数进行统计,包含null。

count(字段名):对某个字段所含的数据项进行统计,不包括null。

 

13、group by 和 having

group by:按照某个字段或者某些字段进行分组

having:对分组后的数据再进行筛选

注意:where 后面不能直接跟分组函数,会报错

数据库操作运算符

 

 

(1) 找出每种职业中年纪最大的人:SELECT id,name,sex,MAX(age),career FROM test1 GROUP BY career;

数据库操作运算符

 

 

(2) having 和 group by是搭档,having离开group不能单独使用。

数据库操作运算符

 

 

 

14、distinct:去重关键字,且必须写在查询字段的前面

数据库操作运算符     数据库操作运算符

相关文章:

  • 2021-11-13
  • 2021-08-24
  • 2022-12-23
  • 2021-12-20
  • 2021-11-20
  • 2021-12-08
  • 2022-12-23
  • 2021-06-29
猜你喜欢
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2021-10-16
  • 2022-02-23
  • 2022-12-23
  • 2021-11-28
相关资源
相似解决方案