I have two tables in a MySQL database. In the first column of data in table A (A1) I have integer values. In the first and second columns of table B (B1 and B2) I also have integer values. I would like to create a query which would give me the values where A1 is within the range B1 – B2. Is this possible to do with a MySQL query?
Here is an example of what I would like to know how to do:
Table A Table B
------- ------- --------
123 12 24
451 450 455
199 202 210
0 499 567
23 5 40
The SQL query I am looking for would return the matching A1, B1, and B2 values:
451 450 455
23 12 24
23 5 40
is as simple as cross joins get. It’s the equivalent of an inner join in MySQL and Oracle at least.