There is a column in options that hold an integer. I want to select the row only if that value % 2 = 1. I know this can be done in 2 queries but is it possible to do it in 1?
+1
A:
At least some versions of SQL (Oracle, Informix, DB2, ISO Standard) support:
WHERE MOD(value, 2) = 1
MySQL supports '%' as the modulus operator:
WHERE value % 2 = 1
Jonathan Leffler
2010-09-21 02:43:58
MOD() for SQL Anywhere; % for Sybase ASE.
pascal
2010-09-21 04:14:10
% for PostgreSQL.
pascal
2010-09-21 04:15:00
A:
select *
from Table
where len(ColName) mod 2 = 1
The exact syntax depends on what flavor of SQL you're using.
Loadmaster
2010-09-21 02:49:09
+1
A:
MySQL, SQL Server, PostgreSQL, SQLite support using the percent sign as the modulus:
WHERE column % 2 = 1
For Oracle, you have to use the MOD function:
WHERE MOD(column, 2) = 1
OMG Ponies
2010-09-21 02:51:11