select * from (select @n:=@n+1 as n, a.* from (select * from tablename order by id desc)a,(select @n:=0)b)c where c.n%2=1 limit 10
首先 :select @n:=@n+1 as n, a.* from (select * from tablename order by id desc)a,(select @n:=0)b 是給每行的記錄添加了序號,字段名為n。
其次:where c.n%2=1 是對2取模值也就是取余數,2代表着隔一行取一條數據,如果是隔兩行取一條數據,就是where c.n%3=1,以此類推。
最后:limit 10 是限制條數為10條。