我有一个名为level_2_tags的表,如果用户选择了二级标记我希望它通过内部联接加入另一个表,否则我希望它加入左连接
IF RLT ID EXISTS BELOW METHOD
SELECT RMC.* INTO #TTEMP
FROM #TRestrictedMainCatagory RMC
JOIN #TRestrictedAssetType RAT
ON RMC.ID = RAT.ID
JOIN #TRestrictedLevelTwo RLT
ON RLT.ID=RAT.ID
ELSE
SELECT RMC.* INTO #TTEMP
FROM #TRestrictedMainCatagory RMC
JOIN #TRestrictedAssetType RAT
ON RMC.ID = RAT.ID
LEFT OUTER JOIN #TRestrictedLevelTwo RLT
ON RLT.ID=RAT.ID
请帮我解决此事