SQL update one column from another column in another table

前端 未结 2 1269
清歌不尽
清歌不尽 2020-12-28 17:55

I read various post\'s prior to this. but none of them seemed to work for me.

As the title suggests, I am trying to update one column from a column in another table

相关标签:
2条回答
  • 2020-12-28 18:28

    According to MySQL documentation, to do a cross table update, you can't use a join (like in other databases), but instead use a where clause:

    http://dev.mysql.com/doc/refman/5.0/en/update.html

    I think something like this should work:

    UPDATE User_Settings, Contacts
        SET User_Settings.Contact_ID = Contacts.ID
        WHERE User_Settings.Account_ID = Contacts.Account_ID
    
    0 讨论(0)
  • 2020-12-28 18:32
    Update tabelName Set SanctionLoad=SanctionLoad Where ConnectionId=ConnectionID
    go
    update tabelName  Set meterreading=meterreading where connectionid=connectionid
    go
    update tabelName  set customername=setcustomername where customerid=customerid
    
    0 讨论(0)
提交回复
热议问题