Could anybody please help me with query
Lets say my table table has rows like 1,2,3,4,5,......50k I would like to select rows likely 1,3,5,....49997,49999 or 1,4,7...49997 Pls help me how to achieve this in sql and as well as in linq Thank you
Could anybody please help me with query
Lets say my table table has rows like 1,2,3,4,5,......50k I would like to select rows likely 1,3,5,....49997,49999 or 1,4,7...49997 Pls help me how to achieve this in sql and as well as in linq Thank you
SQL Server/MySQL/Postgresql/SQLite version using modulo division:
SELECT *
FROM your_table
WHERE id % 2 = 1;
SELECT *
FROM your_table
WHERE id % 3 = 1;
As jarlh mentioned in comment there is MOD(id, x) operator in standard SQL (not working in SQL Server/SQLite)