这是我要完成的查询:
update amdashboard
set (ASCID, ASCFirst, ASCLast, ASCOtherName, ASCAdd1, ASCAdd2,
ASCCity, ASCState, ASCZip, ASCZip4, ASCY2007, ASCY2008, ASCY2009,
ASCY2010, ASCY2011, ASCY2012, ASCEthnicity, ASCGender, ASCMaritalStatus)
= (select id, firstname, lastname, listingspousename, add1, add2,
city, state, zip, zip4, y2007, y2008, y2009,
y2010, y2011, y2012, Ethnicity, Gender, MaritialStatus
from ASCNCOAClean
inner join amdashboard
on ASCNCOAClean.firstname = amdashboard.actorsfirst
and ascncoaclean.lastname = amdashboard.actorslast)
where exists (select id, firstname, lastname, listingspousename,
add1, add2, city, state, zip, zip4, y2007, y2008,
y2009, y2010, y2011, y2012, Ethnicity, Gender,
MaritialStatus
from ASCNCOAClean
inner join amdashboard
on ASCNCOAClean.firstname = amdashboard.actorsfirst
and ascncoaclean.lastname = amdashboard.actorslast);
我无法让它工作......在第一个括号中收到语法错误。所以,我想我只会尝试一个领域。我试过这个:
update amdashboard
set ascid = (select ascncoaclean.id
from ASCNCOAClean
where ASCNCOAClean.firstname = amdashboard.actorsfirst
and ascncoaclean.lastname = amdashboard.actorslast)
where exists (select ascncoaclean.id
from ASCNCOAClean
where ASCNCOAClean.firstname = amdashboard.actorsfirst
and ascncoaclean.lastname = amdashboard.actorslast);
但是,这会返回错误 1242:子查询返回多于 1 行。这似乎很愚蠢。我知道它会返回不止一行...我想要它,因为我需要更新多行。
我错过了什么?