Search code examples
mysqlinsert-update

update query maysql from second table


I have 2 table and need to update one column of 1st table

I have tried with this

update user_details as ud set ud.corporationName =
select cop.corporationName FROM corporation as cop where cop.id = ud.corporation_id

help me to fix it . thanks


Solution

  • You could use an update based on inner join

    update user_details  ud 
    INNER JOIN corporation cop ON  cop.id = ud.corporation_id
    set ud.corporationName =  cop.corporationName