我有一個情況我需要做一個有條件的聯接基於列在表上的一個價值的價值在列條件加入。的Sybase - 基於一列
table_a ta
join table_b tb on
case
when ta.column_1 = 1 then ta.column_2 = tb.column_2
when ta.column_1 = 2 then ta.column_2 = tb.column_2 and ta.column_3 = tb.column_3
when ta.column_1 = 3 then ta.column_2 = tb.column_2 and ta.column_3 = tb.column_3 and ta.column_4 = tb.column_4
end
請指教我應該怎麼做呢?
試圖尋找並得到了一些選項使用left join
,但我不知道該怎麼做。 :(
請告知
非常優雅的解決方案。萬分感謝。 –