Mysql操作之查询语句

查询语句:

  select 查询列表 from 表名 where 筛选条件;

  去重:select distinct 查询列表......

  选择全部:*

  起别名:select 查询列表 as 别名 from 表名

筛选条件:

  一、按条件表达式筛选:

  简单条件运算符:> < = != <> >= <=

  二、按逻辑表达式筛选:

  && || !

  and or not

  三、模糊查询:

    like:select * from employees where name like “王%”

扫描二维码关注公众号,回复: 8030071 查看本文章

    (意思是选择姓王的员工信息%代表任意多个字符_代表任意一个字符)若要选择_和%,则在其后加入\

    between and:可以提高语言简洁度,且包含左右值,左边的值必须小于右边的值。

    in:判断某字段的值是否属于in列表中的某一项,in(。。。。。。)

    is null:查询没有奖金的员工

        select *

        from employees

        where pct is null;

   四、安全等于<=>    可以替代is null和=,但是可读性低

 

猜你喜欢

转载自www.cnblogs.com/algorithmpuppy/p/11963735.html
今日推荐