Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Field replication before MySQL different tables

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Summary

The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support. If you want to know more about it, please see the relevant links below.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report