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'
SQL Server UPDATE JOIN syntax To query data from related tables, you often use the join clauses, either inner join or left join. In SQL Server, you can use these join clauses in the UPDATE statement to perform a cross-table update.
Solution. Select column values in a specific order within rows to make rows with duplicate sets of values identical. Then you can use SELECT DISTINCT to remove duplicates. Alternatively, retrieve rows in such a way that near-duplicates are not even selected.
SQL UPDATE JOIN could be used to update one table using another table and join condition.
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';
This should do it:
UPDATE ProductReviews SET ProductReviews.status = '0' FROM ProductReviews INNER JOIN products ON ProductReviews.pid = products.id WHERE ProductReviews.id = '17190' AND products.shopkeeper = '89137'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With