繁体   English   中英

从另一个表的列更新表中的列值-MySQL

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

我有一个名为“ words”的表,它的列“ score”的所有值均为= 0。 另一个表“ tmp_score”和列“ sc”的值从5000到1。

我想更新表“ words”中的“ score”列,以使“ tmp_score”列中的值(从5000到1)。

表中的单词已经有5000条记录。

所以我需要像在这里复制这些值的东西。

在MySQL中,可以将joinupdate一起使用。 假设表中匹配的列称为word

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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