http://www.perlmonks.org?node_id=11124832


in reply to checking mysql rows continuously

How about something vaguely like this ... an inner-join of a table to itself:

select A.id from table1 A inner join table1 B on (B.id = A.id - 1) where B.status = 'no' and A.status = 'yes'

I think that would give you the id's rows where a "yes" answer immediately follows a "no" answer. (It will not give you initial "yes" answers that are not followed by "no," so manually add "id#1" to your list.) Armed with this answer, select the rows with greater-or-equal IDs and walk them until you encounter a "no."

Although I think that this query will still require "a full table scan," at least it will be the database engine that's doing the heavy lifting.