以下是我的查询和相关错误。我做错了什么?
update aaalogin
set name =
( select aaacontactinfo.emailid
from aaacontactinfo
WHERE aaalogin.user_id = aaausercontactinfo.user_id
and aaausercontactinfo.contactinfo_id = aaacontactinfo.contactinfo_id
);
我得到了
错误:'where子句'中的未知列'aaausercontactinfo.user_id'
答案 0 :(得分:0)
aaausercontactinfo
未包含在FROM
表格列表中,请尝试使用:
UPDATE aaalogin SET name =
(
SELECT aaacontactinfo.emailid
FROM aaacontactinfo, aaalogin, aaausercontactinfo
WHERE aaalogin.user_id = aaausercontactinfo.user_id
AND aaausercontactinfo.contactinfo_id = aaacontactinfo.contactinfo_id
);
答案 1 :(得分:0)
试
UPDATE aaalogin SET name =
(
SELECT aaacontactinfo.emailid
FROM aaacontactinfo, aaausercontactinfo
WHERE aaalogin.user_id = aaausercontactinfo.user_id
AND aaausercontactinfo.contactinfo_id = aaacontactinfo.contactinfo_id
);
子查询中不需要aaalogin。如果使用它甚至可以在子查询中返回多个记录。