0

I have table with two columns. One is start and another column is end. If I give any number it has to pick all matching rows in the table. Example:

start |  End
100   |  200
100   |  500
1     |  345
200   |  400

If i give 123 it should pick:

100 | 200
100 | 500
1   | 345

How to write query for this?

1
  • I have removed the MySQL tag, as you state this is an Oracle question. Commented Sep 1, 2014 at 10:23

2 Answers 2

2

Inclusive select:

SELECT * FROM table
WHERE @value BETWEEN start AND end

Exclusive select:

SELECT * FROM table
WHERE @value > start AND value < end
Sign up to request clarification or add additional context in comments.

2 Comments

But I dont have start and end. I have only number.
How should I understand this: "I have table with two columns. One is start and another column is end."
2

I don't understand your confusion with this task:

with t(strt, En) as (
  select 100,  200 from dual union all
  select 100,  500 from dual union all
  select 1,  345 from dual union all
  select 200,  400 from dual
)
select *
  from t
 where 123 between strt and en

STRT     EN
-----------
 100    200
 100    500
   1    345

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.