Home > database >  How do I specify my data in my column to only produce odd values?
How do I specify my data in my column to only produce odd values?

Time:10-10

The data in my column is numeric and I want to permanently change the numeric data to only contain odd values. For example if I have the data in the column as 101331, 107332, 101333, 101334 I only want the updated table to contain 107331 and 101333.

Original Column New Column
101331 101331
107332 101333
101333
101334

CodePudding user response:

It looks like you just want to select all the odd values.

SELECT * FROM my_table WHERE (original_column % 2) = 1;

Or, if you are trying to delete the even rows

DELETE FROM my_table WHERE (original_column % 2) = 0;
  • Related