May 20, 2010 at 9:40 am
I know this is simple, but it is not working. . . I was getting the obvious error when using the '=' operator, but when using IN, it doesn't work either:
update ProductVariant
set ProductVariant.Price IN (select ret_prc from itm i, product p, ProductVariant pv
where i.itm_cd = p.sku and p.ProductID = pv.ProductID)
I need to update the Price in the ProductVariant table. . . However, I need to join the ProductVariant table and the Product table on ProductID. BUT - the price is in a table called ITM, which needs to be joined to the Product table on SKU.
Any help?
Thanks in advance!
May 20, 2010 at 9:51 am
Donato this is how i usually update a table from multiple sources...note the commented SELECT statement so i can run the bottom portion to test before and after:
SET XACT_ABORT ON
BEGIN TRAN
update pv
SET pv.Price = ret_prc
--SELECT pv.Price,ret_prc,*
FROM ProductVariant pv
INNER JOIN product p
ON p.ProductID = pv.ProductID
INNER JOIN itm i
ON i.itm_cd = p.sku
Lowell
May 20, 2010 at 11:40 am
Lowell (5/20/2010)
Donato this is how i usually update a table from multiple sources...note the commented SELECT statement so i can run the bottom portion to test before and after:
SET XACT_ABORT ON
BEGIN TRAN
update pv
SET pv.Price = ret_prc
--SELECT pv.Price,ret_prc,*
FROM ProductVariant pv
INNER JOIN product p
ON p.ProductID = pv.ProductID
INNER JOIN itm i
ON i.itm_cd = p.sku
Unbelievable. . . Thank you!!! . . . again. 😉
May 20, 2010 at 7:39 pm
donato1026 (5/20/2010)
Lowell (5/20/2010)
Donato this is how i usually update a table from multiple sources...note the commented SELECT statement so i can run the bottom portion to test before and after:
SET XACT_ABORT ON
BEGIN TRAN
update pv
SET pv.Price = ret_prc
--SELECT pv.Price,ret_prc,*
FROM ProductVariant pv
INNER JOIN product p
ON p.ProductID = pv.ProductID
INNER JOIN itm i
ON i.itm_cd = p.sku
Unbelievable. . . Thank you!!! . . . again. 😉
Just to be sure... as Lowell did in the above code, if you have a join in the FROM clause of an UPDATE, one of the things that absolutely MUST be in the FROM clause is the table you're updating. It is possible to write an update without that being true but such an UPDATE will frequently lose its mind and slam several CPU's into the wall for hours trying to do a simple update that should only take several seconds to accomplish.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply