Select every n-th row in mysql table like even or odd.

By | September 23, 2015

Notice: A non well formed numeric value encountered in /home/cinemau0/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

We have faced some problem that we mysql table pulling entire table but we need a particular nth row order. Suppose we have lot of row in the table like 1000 rows but we need nth order row only, In this case, here is the code how to select every n-th row,  you can get particular n order

Demo                            Download

n_th order like

Step 1:  Consider the same table in previous post

nth_order show in mysql

Step 2 : very simple method

Here showing the nth order in even and odd id, that’s it very simple

nth_order show in mysql in even

or Another method for sorting nth order is

Set @row as 1 and add with rownum the div with your nth order

Enjoy code