SQL Server中的条件JOIN [英] Conditional JOIN in SQL Server
本文介绍了SQL Server中的条件JOIN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想基于将参数传递给存储过程来更改表的联接。基于传递的参数应完成连接。
I would like to change join the tables based on the passing parameters to a stored procedure. Based on passing parameter the join should be done.
如何实现?
推荐答案
如果要根据您的情况加入不同的列,使用此
If you want to join different columns based on your condition, use this
SELECT *
FROM tblA A
JOIN tblB B
ON A.col1 =
CASE WHEN <any condition> THEN B.col1
END
这篇关于SQL Server中的条件JOIN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文