开发者

MSSQLCE: Subquery returns parsing error

开发者 https://www.devze.com 2023-03-29 21:39 出处:网络
I\'ve added an ID column (personID) into a table (personList) instead of another field: personPin Now I need to fill empty foreign key field (seenPersonID) of another table (personAttendances)

I've added an ID column (personID) into a table (personList) instead of another field: personPin

Now I need to fill empty foreign key field (seenPersonID) of another table (personAttendances)

UPDATE personAttendances
SET seenPersonID =
(SELECT personID FROM personList WHERE (pers开发者_StackOverflowonAttendances.personPin = personPin))

Why does SQL engine say there is an error parsing the query? Or how can I fill the field on other table?


You need something like

UPDATE personAttendances 
SET seenPersonID = b.personID
FROM personAttendances a
INNER JOIN personList b ON (b.personPin = a.personPin)
0

精彩评论

暂无评论...
验证码 换一张
取 消