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 ?
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 ;
1 answer