SQL Server: unión interna al actualizar [duplicado]

Resuelto LeeTee asked hace 12 años • 2 respuestas

Tengo la siguiente consulta que no funciona. ¿Qué estoy haciendo mal? ¿Es esto siquiera posible?

UPDATE ProductReviews AS R 
   INNER JOIN products AS P 
       ON R.pid = P.id 
SET R.status = '0' 
WHERE R.id = '17190' 
  AND P.shopkeeper = '89137'
LeeTee avatar Mar 07 '12 00:03 LeeTee
Aceptado
UPDATE R 
SET R.status = '0' 
FROM dbo.ProductReviews AS R
INNER JOIN dbo.products AS P 
       ON R.pid = P.id 
WHERE R.id = '17190' 
  AND P.shopkeeper = '89137';
Aaron Bertrand avatar Mar 06 '2012 17:03 Aaron Bertrand

Esto debería hacerlo:

UPDATE ProductReviews
SET    ProductReviews.status = '0'
FROM   ProductReviews
       INNER JOIN products
         ON ProductReviews.pid = products.id
WHERE  ProductReviews.id = '17190'
       AND products.shopkeeper = '89137'
Bridge avatar Mar 06 '2012 17:03 Bridge