How to select odd or even items from a row in SQL?

Ronalds Mazītis picture Ronalds Mazītis · Sep 14, 2013 · Viewed 36.2k times · Source

I need only even or odd items, so I find modulus operation and this doesn't works

SELECT  * FROM table ORDER BY id WHERE MOD (num, 2) = 1 ASC;

Please help me, I'm noob in sql, as I haven't done much in it.

Answer

Steve Homer picture Steve Homer · Sep 14, 2013
SELECT * FROM table WHERE MOD (num, 2) = 1 ORDER BY id  ASC;

Will return all of the odd values of num.