mysql - How to select rows every record+100 value? -


i have table of integer, 2 columns.

  • col1 | col2
  • 47 | 99
  • 56 | 100
  • 100 | 110
  • 147 | 150
  • 156 | 160
  • 200 | 250
  • 247 | 300

let's mysql starts read @ col1, row1, values 47 , 99. want mysql do, select data col1 every values+100. here col1 starts @ 47, mysql should select 47 147 247

fyi : table has 500.000 rows. .. according stats, should return 50,000 rows. need super-fast query.

i had several attempt didn't work out, smth that:

    select *        (             select                  @row := @row +100 rownum, col1            (select @row :=0) r, my_table             ) ranked      rownum % [n] = 1 

do like

select * mytable col1 % 100 =     (select col1 % 100 mytable order col1 limit 1) 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -