BrownTownCoder
BrownTownCoder

Reputation: 1372

SQL Update syntax error with join

I have a table menu_item with id, and min price. I have another table menu_item_variant with menu_item_id, variant_value_id and price1. I want to set menu_item.min_price = menu_item_variant.price1 when variant_value_id=1550. I am using the following command but it's giving me an error. I can't see what is wrong with it. Please help

update menu_item set menu_item.min_price = menu_item_variant.price1 
from menu_item join menu_item_variant 
on menu_item.id = menu_item_variant.menu_item_id 
where variant_value_id = 1550;

ERROR 1064 (42000): 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 'from menu_item join menu_item_variant on menu_item.id = menu_item_variant.menu_i' at line 1

Upvotes: 0

Views: 179

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270633

The proper syntax in MySQL does not use from:

update menu_item join
       menu_item_variant
       on menu_item.id = menu_item_variant.menu_item_id
    set menu_item.min_price = menu_item_variant.price1
where variant_value_id = 1550;

Upvotes: 1

Related Questions