0

Currently I have this table called tbl_yeast

and in my table, i have these columns.

id, name, low, high

sample record would be

id   |   name   |   low   |    high    
1    |    ABC   |     1   |    5      
2    |    AB    |     1   |    4
3    |    C     |     2   |    4     
4    |    CD    |     6   |    10
5    |    CE    |     7   |    9
6    |    CX    |     11  |    15

What I want to do is:

If I have this value of 3 and select based on my low and high column the output would be :

id   |   name   |   low   |    high    
1    |    ABC   |     1   |    5      
2    |    AB    |     1   |    4
3    |    C     |     2   |    4    

As you notice 3 is between in ranges of low and high column values.

And If I have this value of 8 the output would be :

id   |   name   |   low   |    high    
4    |    CD    |     6   |    10
5    |    CE    |     7   |    9

As you notice 8 is between in ranges of low and high column values.

Objective: just want to get all records that is between in these 2 columns (low & high)

0

1 Answer 1

2

You can use the BETWEEN keyword here.

SELECT * FROM `tbl_yeast` WHERE 8 BETWEEN `low` AND `high`;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.