mysql - Update table if conditions met. (update the value from table b to a) corresponding value required -


i have table in have fields 'date', 'time', cost , order_id

table b has fields 'year' 'month' 'hour' 'cost' , order_id fields.

both tables linked "order_id" field. want update table if year, month, hour , order_id same in both tables , update corresponding value table b table field "cost"

i have used statement, query not working? wrong in it? need help

update item a, cost b     set a.cost = b.cost     a.order_id = b.order_id     , year(a.date) = b.year     , month(a.date) = b.month     , hour(a.time) = b.hour 

update item join cost b on a.order_id = b.order_id            , year(a.date) = b.year            , month(a.date) = b.month            , hour(a.time) = b.hour set a.cost = b.cost 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -