Applecore Pages on Microsoft Access

Returning Odd or Even values in a Query

If you wish to only return odd or even values in a Query, then you can use the Mod operator to return the remainder when divided by 2, which will either be 0 or 1, i.e. False or True. The following SQL statement will return all odd values:

SELECT Categories.CategoryID
FROM Categories
WHERE ((([CategoryID] Mod 2)=True));

And the one below returns the even values:

SELECT Categories.CategoryID
FROM Categories
WHERE ((([CategoryID] Mod 2)=False));

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 15:00:05