I have a table like this: (Pay attention to the sequence numbers for every word)
// tablename
+---------+----------+
| word | number |
----------------------
| jack | 1 |
| jack | 2 |
| jack | 3 |
| ali | 1 |
| ali | 2 |
| ali | 3 |
| ali | 4 |
| ali | 5 |
| peter | 1 |
| peter | 2 |
| peter | 3 |
| peter | 4 |
| raj | 1 |
| raj | 2 |
+---------+----------+
Now i need a query to select a range. My range is (for example):
// Range Start
select * from tablename where word='ali' and number='2';
// Range End
select * from tablename where word='peter' and number='3';
In fact I want below result:
+---------+----------+
| word | number |
----------------------
| ali | 2 |
| ali | 3 |
| ali | 4 |
| ali | 5 |
| peter | 1 |
| peter | 2 |
| peter | 3 |
+---------+----------+
How can I do that ?
I have to head out but if your data looks like this with the ID column:
Then you could do this (this is just one way, there are most likely more optimal ways)