简体   繁体   English

如何用另一个值替换MySQL表中列的值

[英]How to replace values of a column in MySQL table with another value

I have a table named as data1 with two columns (Name, address) and an another table named as data2 with same columns 我有一个名为data1的表,其中有两列(Name, address)而另一个表名为data2,具有相同的列

My question: How to assign the value as 'USA' to address column where the value in name columns are equal in both the tables. 我的问题:如何将值“ USA”分配给两个表中name列中的值相等的address列。

UPDATE data2 SET
Address = 'USA'
WHERE Name IN (SELECT Name FROM data1)

暂无
暂无

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

相关问题 如何用另一个表中的列值替换一个MySQL表中的列值 - How to replace values of a column in one MySQL table with values of a column in another table MySQL用另一张表替换列中的逗号分隔值,找到旧值替换为新值 - MySQL replace comma separated values in column with another table find old value to replace with new 在MySQL select的另一个表中用列的值替换列 - replace a column with a column's value in another table in MySQL select 从mysql中的另一个表中选择表并按值替换列字段 - select table and replace column fields by value from another table in mysql 如何用MySQL同一表中不同列的其他值替换我数据库的列值 - how to Replace a Column values of my database with other value of different column in same table in mysql mysql:用另一个表中列的值替换列值 - mysql: Replacing column value with values from column from another table 如何使用字符串替换为另一列的值对 mysql 进行多次更新 - How to make a multiple update on mysql with string replace with value of another column 将值从一个表中的列复制到另一个表中的列,其中另一个值与MySQL匹配 - Copy the values from a column in one table to a column in another table where another value matches MySQL 用条件替换mysql中另一个表中的一列 - Replace a column in another table in mysql with a condition 如何将由值分隔的 mysql 列的值拆分为另一列? - how to split the values of a mysql column delimited by a value into another column?
相关标签
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM