简体   繁体   English

SQL查询以传输THE SAME表的另一列上的所有记录

[英]Sql Query to transfer all records on another column on THE SAME table

Original Table Setup: 原始表格设置:

 Table Name: property_details
 Attribute: property_id, floor_area

Now, a new attribute is added named: total_area. 现在,添加了一个新属性,名为:total_area。

There are already records on property_details table with corresponding id and wanted to copy floor_area data to total_area . property_details表上已经存在具有相应ID的记录,并且想要将floor_area数据复制到total_area (Will do something floor_area later) (稍后将在floor_area做些事情)

For clarification, if this is in excel I will copy the value of A1 to B2 on the same row. 为了澄清起见,如果在excel中,我将在同一行中将A1的值复制到B2。 Pretty simple to demonstrate but can't figured out using sql. 演示很简单,但无法使用sql弄清楚。

Is this possible working on the same table? 这可以在同一张桌子上吗?

Just run an UPDATE statement wherein the value of floor_area is copied to total_area , example, 只需运行UPDATE语句,其中将floor_area的值复制到total_area ,例如,

UPDATE property_details
SET total_area= floor_area

更好的选择是将字段的名称从total_area更改为floor_area,这种情况下执行时间短且效率高,但是ID的ypur问题可能会更好,请先尝试采样或使用少量表

暂无
暂无

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

相关问题 SQL查询将根据另一列中的值省略具有相同ID的记录 - SQL Query that will omit records with the same ID based on values in another column SQL查询-从一个表中选择全部,在另一个表中匹配记录 - SQL Query - select all from one table with matching records in another sql 查询到 select 的所有记录并一起显示同一个表中同名的记录 - sql query to select all records and displaying records together which have same name in same table SQL查询列出所有记录,其中一列的所有值不在另一列中 - SQL Query for listing all records where all values for one column are not in another column 如何编写一个查询,在 sql 中连接同一个表并将一个表的列值与另一个表中的相同列进行比较 - How to write a query that joins same table in sql and compares the column values of one table with same column in another table 在单个mysql查询中将一些金额从一列转移到同一表的另一列 - transfer some amount from one column to another of same table in single mysql query SQL查询可从一个表中获取所有记录,并在另一个表上进行连接,包括任何其他唯一记录 - SQL Query to get all records from one table and join on another including any additional unique records SQL:获取具有相同ID的所有列记录 - SQL: get all column records with same id SQL: select 其他查询未选择的所有记录 - SQL: select all records not selected by another query SQL查询从一个表获取所有记录,除特定记录,按日期,从另一个表 - SQL Query To Get All Records From One Table, Except A Specific Record, By Date, From Another Table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM