In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail the example analysis of Mysql copying a column of data from a table to a column in another table. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Mysql replicates one column from a table to another table
Sometimes, we need to copy an entire column of data from one field to another new field, which is simple, SQL can write:
UPDATE tb_1 SET content_target = content_source
It is roughly written as follows:
Update {your_table} set {source_field} = {object_field} WHERE cause
It is better to have tools such as Navicat, you can directly select a column of data, copy and paste into the column you need. It's fine if it's the same table, and if it's a new table, keep their rows the same. If the number of rows is inconsistent, you can create a new table and copy the columns in so that the number of id will remain the same.
Sometimes these MySQL interface tools report errors, so it's better to use the command line. For example, to copy data from one table field to another table field, you can write:
UPDATE tb_1 INNER JOIN tb_2 ON tb_1.tid = tb_2.tidSET tb_1.tcontent = tb_2.tcontent
Here is a real-world example of writing a link to a static page that PHPCMS has generated into the url field in the phpcms_ content table:
First piece together the required url field columns like this.
SELECT CONCAT (FROM_UNIXTIME (inputtime,'%Y/%m%d'),'/', contentid, '.html') AS dt FROM phpcms_content ORDER BY contentid DESC
Then in the query editor (navicat), copy the entire copy to the url column in the phpcms_ content table.
An example of field replication between different tables:
Requirements: copy the name field of student table to the name field of student_rec table
Student table
Student_ recorder table
Sql implementation:
UPDATE student_rec INNER JOIN student ON student.id = student_rec.student_id SET student_ rec.`name` = student.`name`
Results:
On "Mysql copies a column of data from a table to a column in another table example analysis" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.