I need to check that result of expression in where clause is in range of Integers.
something lke this:
select * from table where (col1 / col2 ) in (1..8).
With (1..8)
representing a range of integers.
I mean that it must be integer, not float. So that I cant use between 1 and 8
, because 1.2 will be correct.
The maximum number of clauses in a WHERE clause is 40.
The IN operator allows you to specify multiple values in a WHERE clause. The IN operator is a shorthand for multiple OR conditions.
The SQL WHERE clause is used to specify a condition while fetching the data from a single table or by joining with multiple tables. If the given condition is satisfied, then only it returns a specific value from the table. You should use the WHERE clause to filter the records and fetching only the necessary records.
You can of course do this:
select * from table where (col1 / col2 ) in (1,2,3,4,5,6,7,8);
or
select * from table where (col1 / col2 ) between 1 and 8
and mod (col1 , col2 ) = 0;
How about
select *
from table
where (col1 / col2 ) BETWEEN 1 AND 8
and (col1 / col2 ) = FLOOR(col1 / col2 )
This simply checks if the fraction is in the interval, and integer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With