MySQL条件查询与排序查询

条件查询

在select语句后加上where+筛选条件

分类:

  1. 按条件表达式筛选
   ​	条件运算符 > < =   <>(!=) >= <=
  1. 按逻辑表达式筛选
   ​	逻辑运算符:&&   ||   !

   ​		  and   or not
  1. 模糊查询
   like

       一般和通配符搭配使用

      ​	通配符:

      ​	% 任意多个字符,包含0个字符

      ​	_  任意单个字符

      ​	想要搜索通配符要使用转义

      ​	可以使用 escape 转义     指定转义符前面的一个字符
        如:
        
           select * from employees where name = '_tom';
           select * from employees where name = '/_tom' escape '/'
        
   ​	between and

          1. 可提高简洁度
          2. 包含边界
  ​	in

   ​	严格等于,不能使用通配符
   ​	is null

   ​	只可判断null值,<=>可以判断null值,也可以判断普通值

排序查询

  select 语句 order by 排序列表 desc/asc

  desc 代表的是降序

  asc代表的是升序

  可以多个字段排序
posted @ 2020-09-07 16:45  LongSL  阅读(434)  评论(0)    收藏  举报