Question : How to select only odd or even rows from a table in Mysql

How to select only odd or even rows from a table in Mysql? Please post the MySQL query

Answer : How to select only odd or even rows from a table in Mysql

First of all, there is no inherent numbering of rows in MySQL, so selecting "odd" or "even" rows is not possible unless you have a field that numbers them.

If you have such a field, say RowNumber, then use

SELECT * FROM Table WHERE MOD(RowNumber) = 0   for the even rows, or
SELECT * FROM Table WHERE MOD(RowNumber) <> 0   for the odd rows.
Random Solutions  
 
programming4us programming4us