我有以下查询可以正常工作。
SELECT ui.userID,
ui.lockedInd,
ui.lockedBy,
ui.lockedReason,
ui.updatedDtTm,
ui.updatedBy,
ua.password,
ua.updatedDtTm,
ua.updatedBy
FROM userInfo ui
JOIN userAuthentication ua
ON ui.userinfoseqid = ua.userinfoseqid
WHERE ui.userID IN (
'userOne',
'userTwo'
)
我想将用户名放入顶部声明的变量中。我有点困惑如何创建变量并添加到它,因为我总是只使用一个值完成变量。须藤代码如下
DECLARE @userIDs
SET @userIDs = "'userOne', 'userTwo'"
SELECT ui.userID,
ui.lockedInd,
ui.lockedBy,
ui.lockedReason,
ui.updatedDtTm,
ui.updatedBy,
ua.password,
ua.updatedDtTm,
ua.updatedBy
FROM userInfo ui
JOIN userAuthentication ua
ON ui.userinfoseqid = ua.userinfoseqid
WHERE ui.userID = @userIDs