Hi all,
I've come across a very interesting problem.. quite lost actually. Suppose I have a table with range of values, like:
id.........From........To
1..........0...........5
2..........6...........10
3..........11...........15
4..........16...........29
So now I have an integer say @MyInt = 8, I want to select that single row in which this integer lies in. In this example, 8 comes between 6 and 10 so it should select row id=2
I obviously cant do
select * from table where From < @MyInt AND To >= @MyInt
because it will select all rows, since all the numbers will be lesser and/or greater..
So how do I select that single row in a situation like this?
Many Thanks!