尝试查询以下嵌套查询
SELECT ur.userID, us.fullname
FROM tbl_user_recipe AS ur JOIN tbl_user_settings AS us ON ur.userID = us.userID
WHERE relationship = 'analyzed' AND userID IN
( SELECT ux.userID
FROM tbl_user_recipe AS ux
WHERE ux.relationship = 'collected'
);
我得到以下内容,并想出原因?
#1052 - Column 'userID' in IN/ALL/ANY subquery is ambiguous
答案 0 :(得分:2)
您需要在此处为别名添加前缀:
WHERE relationship = 'analyzed' AND ur.userID IN