我必须通过查询联系人表将联系人姓名添加到分配表中。
Contact
桌子:
ID First_name Last_Name
-----------------------------------
1234 John Jones
9876 Mary Smith
Assignment
桌子
ContactID Name
-----------------
1234
9876
使用这个查询我得到
子查询返回超过 1 个值。
询问:
update A
set Name = (select distinct first_name + ' ' + last_name from contacts c join Assignments A on c.id = A.contact_id where A.contact_id = c.id)
from Assignments A
join contacts c on c.id = A.contact_id
where c.id = A.contact_id
我错过了什么?