Subscribe Subscribe | Subscribe Comments RSS

Google
 

I was playing in a MySQL database and wanted to only view the records that had odd numbers in the ID field. I was able to accomplish this by selecting SQL and using the following code:

SELECT * FROM ‘tablename’ WHERE id%2=1

You can also display even numbered records with:

SELECT * FROM ‘tablename’ WHERE id%2=0

Replace tablename with the name of the table you are using.

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: