mysql模糊查询语句like与not like的使用与区别

2018-03-28数据库
156

mysql模糊查询like的用法
 
查询user表中姓名中有“王”字的:
 
select * from user where name like '%王%'
 
mysql模糊查询not like的用法
 
查询user表中姓名中没有“王”字的:
 
select * from user where name not like '%王%'
 
查询user表中地址在上海姓名中没有“王”字和所有姓名为空的:
 
select * from user where adress =‘上海’ and name not like '%王%' or name is null
 
查询user表中地址在上海姓名中没有“王”字和地址在上海姓名为空的:
 
select * from user where adress =‘上海’ and (name not like '%王%' or name is null)

The End

相关推荐

liunx mysql root账户提示:Your password has expired. To log in yo
liunx mysql root账户提示:Your password has expired. To log in you must change it using a client that supports expired passwords,要怎么操作呢? 1、修改 /etc/my.cnf,在 [mysqld] 小节下添加一行:skip-grant-tables=1 这一行配置让 mysqld 启动...
2024-12-24 数据库
149

快速解决PostgreSQL中的Permission denied问题
下面是针对PostgreSQL中的权限问题的完整攻略。...
2023-12-07 数据库
3413

MySQL时间类型和模式详情
MySQL是一种流行的关系型数据库系统,它提供了多种时间类型和模式,用于存储和处理时间数据。本文将详细介绍MySQL时间类型和模式的详细攻略。...
2023-12-07 数据库
15

VMware中安装CentOS7(设置静态IP地址)并通过docker容器安装mySql数据库(超详细教程)
首先在官网下载CentOS7镜像,并在VMware虚拟机中新建一台CentOS7虚拟机,将镜像挂载到虚拟机中并启动。...
2023-12-07 数据库
11

SpringBoot项目报错:”Error starting ApplicationContext̷
首先,当我们使用Spring Boot开发项目时,可能会遇到Error starting ApplicationContext错误,一般这种错误是由于配置文件、依赖包或者代码逻辑等原因引起的。下面我将提供一条包含两条详细示例说明的完整攻略,用来解决上述问题。...
2023-12-07 数据库
489

Postgresql 赋予用户权限和撤销权限的实例
下面我将详细讲解如何为PostgreSQL数据库中的用户授予权限和撤销权限,包括两个实例。...
2023-12-07 数据库
30