Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

join tables based on condition

$
0
0

declare @id int

select * 
from tablea inner join  case when @id = 1 then tableb on a.id = b.id
                             when @id = 2 then tablec on a.id = c.id
                             else 'dont join'
                             end

can some one please help me


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>