我有兩個表,即profile
和table_1
,profile
是父表,table_1
是子表。我有一個email
列在這兩個表中,我想要做的是例如'[email protected]'
在子表列email
應更新父列表列record
的每列與1
其中父email
列是[email protected]
。更新父表
在where語句中,我使用兩個表的主鍵來完成它,但由於它們不相同,所以會導致錯誤。
update profile
set record= (
select table_1.record
from Table_1
where profile.profile_id = Table_1.profile_id
)
,但是當我用下面這一個,我知道會工作,它給我一個錯誤"Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >="
update profile
set record = (
select table_1.record
from Table_1
where profile.email = Table_1.email
)
請我如何與電子郵件列的更新工作,但不是主鍵列
查詢必須只返回一行,可能與TOP 1 – mxix 2014-10-28 20:18:04
更新的聯接。 – Mihai 2014-10-28 20:19:24