Select Rows with id having even number

solanki kaushik picture solanki kaushik · Jan 31, 2016 · Viewed 140.8k times · Source

I am passing a simple query where I am searching for specific rows where OrderID is an even number

SELECT * 
FROM Orders 
WHERE mod(OrderID,2) = 0;

Error :

Syntax error (missing operator) in query expression 'mod(OrderID,2) = 0'.

Answer

Tim Biegeleisen picture Tim Biegeleisen · Jan 31, 2016

You are not using Oracle, so you should be using the modulus operator:

SELECT * FROM Orders where OrderID % 2 = 0;

The MOD() function exists in Oracle, which is the source of your confusion.

Have a look at this SO question which discusses your problem.