I have one table and I'd like to decide which table join depending on the value of a field.
I have the table T and there is a field Type, so if Type=1 then I have to join with Table2 and if Type=2 I have to join with Ta
Sql-server – How to join one table or other depending on a field value
sql serversql-server-2008
Related Question
- SQL Server 2008 – Set Date Value Based on Other Row Values
- SQL Server – How to Make a Query Sargable?
- Sql-server – convert date format for this value ‘19920000’
- Sql-server – Create Field With Default Value Of Different Field With No Data Loss
- Sql-server – NULL out value in table 1, depending on a time-log in table 2
- Sql-server – Delete rows in a table based on a table value parameter
- SQL Server – Two Inner Joins on the Same Field to Retrieve Data
Best Answer
Short answer, you can't. Maybe you can do something like:
to return something (must be same type) from either t1 or t2 you can use: