简体   繁体   中英

Update column values in a table from another table's column - mysql

I have a table named "words" it has a column "score" has all values =0. and another table "tmp_score" and has a column "sc" has values from 5000 to 1.

I want to update the column "score" in the table "words" to have the values in "tmp_score" column (from 5000 to 1).

I already have 5000 record in the table words.

so i need something like copying these values here.

In MySQL, you can use join with update . Assuming the column that matches in the tables is called word :

update words w join
       tmp_score sc
       on w.word = sc.word
    set w.score = w.sc;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM