我的数据库:
+------------+
| Number |
+------------+
| 8883277777 |
+------------+
| 8883555354 |
+------------+
| 8181888867 |
+------------+
| 8881143185 |
+------------+
当我们这样做时:
SELECT * FROM numbers WHERE Number LIKE "88%"
它将导致:
8883277777、8883555354、8881143185
当我们这样做时:
SELECT * FROM numbers WHERE Number LIKE "%88%"
它将导致:
8181888867
当我们这样做时:
SELECT * FROM numbers WHERE Number LIKE "%77%"
它将导致:
8883277777
获取 %yyyy% 的查询应该是什么?
其中y =任何数字(0/1/2/3/4/5/6/8/9)。
结果将是:
8883277777,8181888867
答案 0 :(得分:3)
似乎您正在使用正则表达式,可以使用以下查询:
SELECT
*
FROM
numbers
WHERE
Number REGEXP '(0{4}|1{4}|2{4}|3{4}|4{4}|5{4}|6{4}|7{4}|8{4}|9{4})'
您在寻找什么吗?
答案 1 :(得分:2)
您可以尝试使用OR
SELECT *
FROM numbers
WHERE Number LIKE "%0000%"
OR Number LIKE "%1111%"
OR Number LIKE "%2222%"
OR Number LIKE "%3333%"
OR Number LIKE "%4444%"
OR Number LIKE "%5555%"
OR Number LIKE "%6666%"
OR Number LIKE "%7777%"
OR Number LIKE "%8888%"
OR Number LIKE "%9999%"