码迷,mamicode.com
首页 > 其他好文 > 详细

运算符操作

时间:2018-08-30 22:45:36      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:空字符串   字符   name   fan   rom   null   空值   style   运算   

1、数值比较/字符比较
  1、数值比较 := != > >= < <=
  2、字符比较 := !=

2、逻辑比较
  1、and (两个或多个条件同时成立)
  2、or (任意一个条件成立即可)

3、范围内比较
  1、where 字段名 between 值1 and 值2
  2、where 字段名 in(值1,值2,...)
  3、where 字段名 not in(值1,值2,...)

select * from sanguo where ((id in(1,3,4)) and country = "蜀国") or name = "貂蝉";
+------+-----------+--------+--------+------+---------+
| id   | name      | gongji | fangyu | sex  | country |
+------+-----------+--------+--------+------+---------+
|    1 | 诸葛亮    |    120 |     20 | 男   | 蜀国    |
|    3 | 关羽      |    188 |     60 | 男   | 蜀国    |
|    6 | 貂蝉      |    666 |     10 | 女   | 魏国    |
+------+-----------+--------+--------+------+---------+

 

4、匹配空、非空
  1、空 :where name is null
  2、非空:where name is not null
  3、注意
    1、NULL :空值,只能用 is 或者 is not 去匹配
    2、"" :空字符串,用 = 或者 != 去匹配

5、模糊比较
  1、where 字段名 like 表达式
  2、表达式
    1、_ : 匹配单个字符
    2、% : 匹配0到多个字符
      ## NULL不会被统计,只能用is、is not去匹配

运算符操作

标签:空字符串   字符   name   fan   rom   null   空值   style   运算   

原文地址:https://www.cnblogs.com/zengsf/p/9563075.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!