Using Update and Left Join in SQL together not working - example

I need to use UPDATE and LEFT JOIN functions together in SQL, but it is not working. I am receiving the error notification: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN

The SQL is:
UPDATE items AS i SET item_price = '149.00' LEFT JOIN brands AS b ON i.item_brand = b.brand WHERE b.quantity > 15 ;
Could you please provide a working example of UPDATE and LEFT JOIN functions used together ?

0
give a positive ratinggive a negative rating
28 Aug 2020 at 07:01 PM
Hi,

To use UPDATE and LEFT JOIN together in SQL, you have to move LEFT JOIN before SET. The code should look like:

UPDATE items AS i LEFT JOIN brands AS b ON i.item_brand = b.brand SET item_price = '149.00' WHERE b.quantity > 15 ;
0
give a positive ratinggive a negative rating
31 Aug 2020 at 11:39 AM
Tim
Share on FacebookShare on TwitterShare on LinkedInSend email
x
x
2024 AnswerTabsTermsContact us