SQL Question

How to using PostgresSQL to select between with values condition in two sets of data?

I have two query:

  1. Select * from table1 where my_value between value1 and value2;

  2. Select value1, value2 from table2;

And the sets of value1 and value2 in table2 is unique.
How can I plugin all result sets of query 2 in where statements of the first query ?

Answer Source

You could join the two tables:

FROM   t1
JOIN   t2 ON t1.myvalue BETWEEN t2.value1 AND t2.value2
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download