mysql每日一题0809--每行包含某个特定数据或者字符 like regex like length

mysql每日一题0809--每行包含某个特定数据或者字符 like regex like length

测试数据

CREATE TABLE T0809
(
ID INT,
DATA VARCHAR(10)
);

INSERT INTO T0809 VALUES(1,'8'),
(2,'88'),
(3,'7,8'),
(4,'6,7,8'),
(5,'8,9'),
(6,'7,88')

solution

select *   from T0809 where 
LENGTH(data)-LENGTH(replace(data,'8','')) <2 
and LENGTH(data)-LENGTH(replace(data,'8',''))>0




SELECT t.*FROM t0809 tWHERE REGEXP_Count(t.data,8,1)=1


上一篇:day27 Java 动态代理 正则表达式


下一篇:正则表达式