How to query data of changes in a column in MySQL
Maybe I can update mysql version. If I will update how can I do it? 


In MySQL 8+ the query will be

with 
cte0 as ( select *, 
                 lag(value) over (order by run_date) lg, 
                 lead(value) over (order by run_date) ld
          from test),
cte1 as ( select *, 
                 row_number() over (order by run_date) rn
          from cte0
          where value = 1 
            and (lg = 0 or lg is null)),
cte2 as ( select *, 
                 row_number() over (order by run_date) rn
          from cte0
          where value = 1 
            and (ld = 0 or ld is null))
select cte1.id `min(run_date)`, 
       cte2.id `max(run_date)`, 
       cte2.seed - cte1.seed difference
from cte1, 
     cte2
where cte1.rn = cte2.rn;




min(run_date) | max(run_date) | difference
------------: | ------------: | ---------:
            3 |             5 |          7
            9 |            13 |         84



db&lt;>fiddle here