我正在使用sql-server 2012,並且在更新表中有一個奇怪的問題。執行更新查詢後,子查詢返回了超過1個值的錯誤
我的選擇查詢返回的行樹,猶如如下:
select * from
TAble1 p join
(select ProductId=max(ProductId) from Table2 s group by s.ProductId) pin on p.id=pin.ProductId
where p.categoryid=238
和返回的行:
現在,當我運行此更新查詢:
update TAble1 set sizing=0 from
TAble1 p join
(select ProductId=max(ProductId) from TAble2 s group by s.ProductId) pin on p.id=pin.ProductId
where p.categoryid=238
我得到這個錯誤:
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.
問題在哪裏查詢?
這是一個觸發器。謝謝! – Mashtani
觸發器在一行更新或其他東西后運行? – Mashtani
它在統計之後運行,無論它是更改一行還是更多。 –