I have an issue where in I want to retrieve departments from 10 to 80 and then department 200.
The department table's is as follows:
Capture1.JPG (142.56 KB)
I know I can use the IN operator but I do not want to use IN operator instead use BETWEEN operator. However BETWEEN (only 2 ranges) works well for 10(1st range) to 80 (2nd range). But when it comes to 200 how can I use it?
I have approached the issue the following way using UNION ALL operator:
select department_id, department_name, manager_id, location_id
from t1_departments t1
where t1.department_id between 10 and 80
UNION all
select department_id, department_name, manager_id, location_id
from t1_departments t
where t.department_id = 200;
The output is (which appears OK to my eye):
Capture1.JPG (109.99 KB)My question is:
a) is my approach correct?
b) if not is there a better way to do it?