Choosing rows where the remainder (modulo) is 1 after dividing by 2?

Parameters containing integers have a column. I want to select a row only if this value is% 2 = 1.

I know that this can be done in 2 queries, but is it possible to do this in 1?

+41
sql database select where-clause modulus
Sep 21 '10 at 2:36
source share
4 answers

Support for MySQL, SQL Server, PostgreSQL, SQLite using the percent sign as a module:

WHERE column % 2 = 1 

For Oracle, you should use the MOD function :

 WHERE MOD(column, 2) = 1 
+65
Sep 21 '10 at 2:51
source share

At least some versions of SQL (Oracle, Informix, DB2, ISO Standard) support:

 WHERE MOD(value, 2) = 1 

MySQL supports "%" as a module statement:

 WHERE value % 2 = 1 
+16
Sep 21 '10 at 2:43
source share

select * from table where value % 2 = 1 works fine in mysql.

+1
Sep 21 '10 at 2:45
source share

Note: Do not pay attention to this answer, as I must have misunderstood this question.

 select * from Table where len(ColName) mod 2 = 1 

The exact syntax depends on what taste of SQL you use.

0
Sep 21 2018-10-21T00:
source share



All Articles