I was just wondering on how create a query that in such a way it will check if the column is in between in a reference table.
such as
SELECT *
FROM Table1 WHERE Column1 BETWEEN ( SELECT Column1 , Column2 FROM TABLE2 )
I just don’t know how to implement it in a correct way.
Thank you.
If you can have overlapping ranges in
Table2, and all you want are (unique)Table1records that are in any range inTable2, then this query will do it.You can also solve this using JOINs, if the ranges in Table2 are not overlapping, otherwise you will need to use either
DISTINCTorROW_NUMBER()to pare them down to uniqueTable1records.