2014-08-27 70 views
0

不明確的列名試圖查詢以下嵌套查詢PHP和MySQL:如何解決子查詢

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

可能重複[PHP和MySQL:如何解決在JOIN操作不明確的列名?(HTTP://計算器。 COM /問題/ 431391/PHP MySQL的知識對解決歧義,列名,在聯接操作) – 2014-08-27 14:22:01

回答

2

你需要的別名前綴表此處的

WHERE relationship = 'analyzed' AND ur.userID IN