子查询返回多个值但不应该返回

时间:2015-02-23 20:13:41

标签: sql sql-server sql-server-2008 join set

我尝试更新lt_esp表 - 将season_desc列设置为tr_season列中的描述值。

lt_esp表中的季节值等于tr_season中的id。表中的每一行都有一个季节值,但是季节值不是唯一的,它可以重复多行可以有赛季= 224.我想要发生的是如果赛季= 224那么我们在tr_season中找到id 224无论那里有什么描述,我们都会更新我们的lt_esp表。

update a
set a.season_desc = b.[description]
from [tr_esp] a
join tr_season b on a.season = b.id
where customer_no = 3773541 
-- a.season_desc is null

tr_season有id,description和其他一些问题 tr_esp有季节(相当于id)和season_desc(相当于描述)

我不断收到此错误消息,但它没有意义,因为每行只有一个季节值。

Msg 512, Level 16, State 1, Procedure ltg_esp_trigger, Line 11
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

0 个答案:

没有答案
相关问题