MySql - Update table using select statment from same table

前端 未结 5 489
执念已碎
执念已碎 2020-12-01 11:49

I\'m trying to update row in a table using values from a different row (and different columns) in the same table. Something along the lines of this, although my syntax produ

5条回答
  •  执念已碎
    2020-12-01 12:22

    You are not need to this query

    SELECT field_id_46,field_id_47 FROM table WHERE entry_id = '36'
    

    You should just do this:

    UPDATE table SET (field_id_60,field_id_61) ('coming_value','other_value') WHERE entry_id = '45';
    

    Also you can do this with 2 different coloumns.I think you can do like this.But It might i havent got any idea.You should split this query in which language do you use.In first method you should use this query.

    SELECT field_id_46,field_id_47 FROM table WHERE entry_id = '36'
    

    And You can also return String that is coming from this data.Then you can use this returned value in update function.

提交回复
热议问题