我希望在某些条件成立时进行内连接
case
when (select dbo.fnGetProduct_config('CATEGORY_NAME','',''))='XYZ'
then inner join product_master t12 on t12.id=t1.product_id
END
答案 0 :(得分:5)
您不能使用条件来决定是否加入(动态sql除外),但您可以将谓词添加到连接....
...
from table1
inner join product_master t12 on t12.id=t1.product_id and dbo.fnGetProduct_config('CATEGORY_NAME','',''))='XYZ'
答案 1 :(得分:-1)
SELECT * FROM TABLE1 T1
INNER JOIN TABLE2
ON (fn(T1.Blahblah)==1 AND /*other conditions*/)