使用 php 在某些 mysql 行中查找模式


Find pattern in some mysql row with php

我在mysql中有一个包含2列的表:id(auto_increment)和value(int 0/1)。我想找出有多少存在与 PHP 表中的模式"101"匹配。例:

身份证 |价值----------1 |  12 |  1   --3 |  0 | => (1)4 |  1   --5 |  0 |=> (2)6 |  1   --7 |  08 |  09 |  110 |  1..|  ....|  ..5000 | 1  --5001 | 0 | => (n)5002 | 1  --5003 | 1...  | ...

使用数组比通过 mysql 搜索模式更快(将 mysql 的值导入数组)?

任何机构知道如何使用 PHP 查找整行中有多少"101"的存在?

谢谢-千斤顶-

以下是在SQL中执行此操作的方法。

select count(*) match_count
from TheTable t1
join TheTable t2 on t1.id+1 = t2.id
join TheTable t3 on t1.id+2 = t3.id
where t1.value = 1 and t2.value = 0 and t3.value = 1