当某些条件为真时,我想进行内部连接
case
when (select dbo.fnGetProduct_config('CATEGORY_NAME','',''))='XYZ'
then inner join product_master t12 on t12.id=t1.product_id
END
当某些条件为真时,我想进行内部连接
case
when (select dbo.fnGetProduct_config('CATEGORY_NAME','',''))='XYZ'
then inner join product_master t12 on t12.id=t1.product_id
END
您不能使用条件来决定是否加入(动态 sql 除外),但您可以将谓词添加到联接中......
...
from table1
inner join product_master t12 on t12.id=t1.product_id and dbo.fnGetProduct_config('CATEGORY_NAME','',''))='XYZ'
SELECT * FROM TABLE1 T1
INNER JOIN TABLE2
ON (fn(T1.Blahblah)==1 AND /*other conditions*/)