[MySQL文章5]数据库查询,修改,删除中的运算符操作

版权声明: https://blog.csdn.net/Geroge_lmx/article/details/83352336

1.数字比较 & 字符比较 & 逻辑比较

     数值:=,!=,>,>=,<,<=

     字符:=,!=

     逻辑:and or

2.范围内比较

     between value1 and value2

     in(value1,value2,...)    、   not in(value1,value2,...)

3.匹配空和非空

     空:is null

     非空:is not null

4.示例:

     查找姓名为空的男英雄

          select * from WANGZHE where name is null and sex='男';

     查找姓名为""的英雄的id,姓名和国家

          select id,name,country from WANGZHE where name="";

备注:

     1. NULL:空值,必须用is或者is not去匹配

     2. "":空字符串,只能用=或者!=去匹配

5.模糊比较

     1)where 字段名 like 表达式

     2)表达式:

          _ : 匹配单个字符

          % : 匹配0到多个字符

     3)示例:

          select * from WANGZHE where name like "_%_";

          select * from WANGZHE where name like "%";  #不含NULL,NULL用is[is not]匹配

          select * from WANGZHE where name like "___";

          select * from WANGZHE where name like "赵%";

          show tables like "%sa%";

          show variables like "%character%";

猜你喜欢

转载自blog.csdn.net/Geroge_lmx/article/details/83352336
今日推荐