当前位置:首页 > 数据库 > 正文内容

mysql like 模糊查询和REGEXP 正则查询

root5年前 (2022-01-12)数据库1637

like

%:表示任意个或多个字符。可匹配任意类型和长度的字符。

_:表示任意单个字符。匹配单个任意字符,它常用来限制表达式的字符长度语句:(可以代表一个中文字符)

匹配”三”字结尾

select * from user where name like "%三"


匹配name有且只有一个字符在“三”前面

select * from user where name like "_三"


REGEXP 

跟正则表达式

匹配三开头的name

select from  user where name REGEXP "^三";

匹配三结尾的name

select from  user where name REGEXP "三$";


扫描二维码推送至手机访问。

版权声明:本文由一叶知秋发布,如需转载请注明出处。

本文链接:https://zhiqiu.top/?id=205

分享给朋友:

相关文章

mysql启动失败 日志InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT between the checkpoint 3485

mysql报错Ignoring the redo log due to missing MLOG_CHECKPOINT betweenmysql版本:5.7.33系统版本:ubuntu16.04由于电脑突然关闭,跑在VMware里面的mys...

mysql 导出csv格式数据

mysql -e "select * from newsdb.t_hk_stock_news where id <100  ...

postgresql 导入导出sql 文件

pg_dump  -h localhost -U postgres -t tablename databasename >./test.sql导出 -t 表名  psql -d test1 -U...

postgresql 的安装使用

安装centos系统 9.6版本# Install the repository RPMsudo yum install -y https://download.postgresql.org/pub/repos/yum/repor...

被Navicat坑哭的日常,版本问题

mysql5.7DROP TABLE IF EXISTS `xxx_copy1`;CREATE TABLE `xxx_copy1`  (  `id` int(11) UNSIGNED NOT NULL AUTO_INCR...

清空postgresql的缓存

系统:centos,版本:postgresql-9.6因为要测试postgresql的性能,当多次查询的时候查询结果会因为缓存用时很短,不能模拟出现实使用的场景。因此需要清除缓存。首先stop掉postgresqlsystemctl sto...