The existing code I’m trying to modify goes something like:
SELECT * FROM <table1>
JOIN
( SELECT * FROM <table2>
WHERE GETDATE() BETWEEN <fields from table2> )
I need to change the GETDATE() to reference a field from table1
I’d prefer to make the changes as small and local as possible as to not cause issues elsewhere so I’m hoping there’s some simple way I can reference the current values from the initial SELECT.
Give the table an alias and you can refer to it in sub queries using that subquery.
Though you should be able to just use joins: