Field replication between different MySQL tables

Source: Internet
Author: User


Sometimes, we need to copy the data in the entire column of a field to another new field, which is very simple. The SQL statement can be written as follows:

UPDATE tb_1 SET content_target = content_source;

The syntax is as follows:

Update {your_table} set {source_field }={ object_field} WHERE cause

Tools such as Navicat are better. You can directly select a column of data and copy and paste it into the column you need. If it is the same table, there is no problem. If it is a new table, ensure that their rows are consistent. If the number of rows is different, you can create a new table and copy the columns to make sure that the number of IDS is consistent.

Sometimes these MySQL interface tools will report errors, and it is better to use the command line at this time. For example, to copy a table field data to another table field, you can write it as follows:

UPDATE tb_1 inner join tb_2 ON tb_1.tid = tb_2.tid
SET tb_1.tcontent = tb_2.tcontent

The following is an example of writing a link to a static page generated by PHPCMS to the url field in the phpcms_content table:
First, piece together the required url field columns.

Select concat (FROM_UNIXTIME (inputtime, '% Y/% m % d'),'/', contentid, '.html') AS dt FROM phpcms_content order by contentid DESC

Then, in the editor (navicat), copy the entire segment to the url column in The phpcms_content table.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.