Update Join in Mysql Query

Its very difficult to write and ambiguous task to write a select query when doing update.

so mysql provide us Update Join Query

its syntax is quite different than sql and oracle to write update join


update your_table your_table alias
inner join your_inner_join_table your_inner_join_table_alias
ON your_table.primary_id = your_inner_join_table.co_relational_primary_id
set your_table_update_field = value
where <condition> 


Update specials s inner join products p
on p.products_id=s.products_id
set s.specials_new_products_price = p.products_price-2
where p.products_price < s.specials_new_products_price

i hope this will help you
best of luck

One Response to “Update Join in Mysql Query”

  1. kerjo Says:

    thanks this is very useful to me

Speak Your Mind

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: