21,891
社区成员
发帖
与我相关
我的任务
分享
mysql> select * from s;
+-------------+
| phone |
+-------------+
| 15980021111 |
| 15980022222 |
| 15980023333 |
| 15980024444 |
| 15980025555 |
| 15980022111 |
| 15980021422 |
+-------------+
7 rows in set (0.02 sec)
mysql> select if(find_in_set(right(phone,3),
-> '000,111,222,333,444,555,666,777,888,999')>0,
-> if(find_in_set(right(phone,4),
-> '0000,1111,2222,3333,4444,5555,6666,7777,8888,9999')>0,'AAAA','AAABBB'),
-> '普通号') rank
-> from s;
+--------+
| rank |
+--------+
| AAAA |
| AAAA |
| AAAA |
| AAAA |
| AAAA |
| AAABBB |
| 普通号 |
+--------+
7 rows in set (0.00 sec)
SELECT 'AAAA',mobile_number,Right(mobile_number,4) as a FROM t_konio t Having Replace(a,Right(a,1),'')='';
SELECT 'AAABBB',mobile_number,SUBSTRING(mobile_number,6,3) as a,Right(mobile_number,3) as b FROM t_konio t Having Replace(a,Right(a,1),'')='' And Replace(b,Right(b,1),'')='';
SELECT 'AABBCC',mobile_number,SUBSTRING(mobile_number,6,2) as a,SUBSTRING(mobile_number,8,2) as b,Right(mobile_number,2) as c FROM t_konio t Having Replace(a,Right(a,1),'')='' And Replace(b,Right(b,1),'')='' And Replace(c,Right(c,1),'')='';
SELECT 'AAAAB',mobile_number,SUBSTRING(mobile_number,7,4) as a FROM t_konio t Having Replace(a,Right(a,1),'')='';
select '15980021111' REGEXP '^[0-9]{7}([0-9])\\1{3}$';#ok
select '15980222111' REGEXP '^[0-9]{5}([0-9])\\1{2}([0-9])\\2{2}$';#bad
select '15980221133' REGEXP '^[0-9]{5}([0-9])\\1([0-9])\\2([0-9])\\3$';#bad
select '15980011112' REGEXP '^[0-9]{6}([0-9])\\1{3}[0-9]$';#ok
select if(find_in_set('15980021111',number)>0,'AAAA','') 等级
union all
select if(find_in_set('15980222111',number)>0,'AAABBB','')
.....................