SQLTeam.com | Weblogs | Forums

Help with sql update statement

sql2008

#1

Hello,
Im after some help performing an update statement please. We have a product table. pres.scheme.stockm
products have multiple warhouses.
theres three anayasis fields called
analysis_a
analysis_b
analysis_c
Warehouse is BE and BF
where a product has both a BE and BF record and the three fields are blank against the BE, I want to use the values of the three records in the BF the populate the BE. Could anyone assist please.


#2

Can we get the actual table definition? I'm kind of guessing what it looks like. With that in mind, this might be completely out in left field:update e set analysis_a = f.analysis_a, analysis_b = f.analysis_b, analysis_c = f.analysis_c from products e inner join products f on e.ProductName = f.ProductName -- Same Product and e.warehouse = 'BE' -- different warehouses and f.warehouse = 'BF' where e.analysis_a = '' -- All are blank and e.analysis_b = '' and e.analysis_c = ''