有没有一种方法可以执行条件连接,如下所示:
CREATE TABLE #Entity
(
[AutoID] [int],
[Code] [nvarchar](50) NOT NULL,
)
INSERT #Entity
EXEC Entity_GetEntitiesByUserId @UserID
DECLARE @Condition bit = 0
SELECT * FROM [Stuff] s
IF @Condition = 1 BEGIN
INNER JOIN
(
SELECT Code as eCode from
#Entity
) e
ON E.eCode = s.EntityCode
END
WHERE DeletedBy IS NULL
谢谢。