SQL Server - inner join when updating

LeeTee picture LeeTee · Mar 6, 2012 · Viewed 800.8k times · Source

I have the below query which does not work. What am I doing wrong? Is this even possible?

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'

Answer

Aaron Bertrand picture Aaron Bertrand · Mar 6, 2012
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';