I am using SQL Server 2005. I am trying to join two tables together, but only when the column value in the main table is true. Like this:
select * from T1
join T2 on T1.value = T2.value
where T2.value2 = 'variable2'
and T2.value3 = 'variable3'
There is a column value in T1 that says I need to use the values in T2. I could refer to the where argument, but it will always join the table, and if the value in T1 is false, in T2 there are no values to join, so the selection does not return rows.
You can't put a case around a connection, so I'm a little stuck with this ... can anyone help?
source
share