sql server - Subquery returned more than 1 value. SQL error -
this error has it. dont know do. please me.
subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression.
update kho /*set kho.xuat = sum(phieuxuat.sl)*/ set kho.xuat = (select sum(phieuxuat.sl) sluong phieuxuat group phieuxuat.mavt) kho inner join phieuxuat on (kho.mavt = phieuxuat.mavt)
this means subquery returned more 1 row not allowed. can write update
statement as:
update k set k.xuat = (select sum(p.sl) phieuxuat p p.mavt = k.mavt) kho k
note added where
clause inside subquery. removed join
prevent multiple updates on same row.
Comments
Post a Comment