我有一个问题:我正在尝试完全更新 SQL Server 2012 中的临时表(在存储过程中),但它只更新与我的描述匹配的第一个条目。这是代码:
create table #t (store_name varchar(30),
product_name varchar(30),
price int,
valab_since date,
valab_until date,
best_offer varchar(3))
--some code that populates my table
update #t set best_offer = 'yes'
where price = (select min(price) from Cataloage as c
INNER JOIN Produse as p
on c.codP = p.codP
where p.denumire = #t.store_name)
update #t set best_offer = 'no'
where price > (select min(price) from Cataloage as c
INNER JOIN Produse as p
on c.codP = p.codP
where p.denumire = #t.product_name)
select * from #t
Cataloage
并且Produse
是我使用的一些表。