Home Blog SQL Notes

Select even and odd rows

Published:


How can you select all the even number records from a table? All the odd number records?

To select all the even number records from a table:

Select * from table where id % 2 = 0

To select all the odd number records from a table:

Select * from table where id % 2 != 0
Comment