简体   繁体   English

Oracle SQL:使用来自同一表的其他列的数据更新表

[英]Oracle SQL: Update a table with data from another columns of the same table

Table: names 表:名称

Id  name    namemaster
--  ----    ----------
1   tomato  tomato/999
2   lettuce lettuce/999
3   carrot  carrot/999

In oracle SQL, how do I run an sql update query that can update table colum "names.namemaster" with name of the table colum "names.name" using the same id? 在oracle SQL中,如何运行一个SQL更新查询,该查询可以使用相同的ID用表列“ names.name”的名称更新表列“ names.namemaster”? So the end result I would get is: 因此,我得到的最终结果是:

Table: names 表:名称

Id  name    namemaster
--  ----    ----------
1   tomato  tomato
2   lettuce lettuce
3   carrot  carrot

Do you just want a simple update ? 您是否只想进行简单的update

update names
    set namemaster = name;

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

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