将语句转换为连接

时间:2016-02-19 05:41:49

标签: sql sql-server

请帮我用连接写

(SELECT isvisibleforclients FROM user_assigned_packages WHERE (user_assigned_packages.UserID = 
(SELECT ParentUserID FROM users WHERE users.UserID = UserID)))

2 个答案:

答案 0 :(得分:2)

SELECT isvisibleforclients FROM user_assigned_packages uap
JOIN users us ON
uap.UserID = us.ParentUserID
AND us.UserID = UserID

假设您的代码中传递了 UserID

答案 1 :(得分:0)

试试这个...

SELECT 
isvisibleforclients 
FROM 
user_assigned_packages a 
inner join users b on a.UserID =b.ParentUserID and  b.UserID = userID