MySQL field to copy table fields to other tables

Source: Internet
Author: User

Sometimes we need to copy the entire column of data from one field to another in a new field, which is simple enough for SQL to write:

UPDATE tb_1 SET content_target = Content_source;

The approximate wording is as follows: Name Shi Casino

Update {your_table} set {Source_field} = {Object_field} WHERE cause

Have Navicat and other tools better, you can directly select a column of data, copy and paste into the column you want. If it's the same table that's fine, if it's a new table, keep their number of rows consistent. If the number of rows is inconsistent, you can create a new table and copy the columns so that the number of IDs remains the same.

Sometimes these MySQL interface tools will error, this time with the command line better. For example, you can copy a table field data to a different list of fields, so write:

UPDATE tb_1 INNER JOIN tb_2 on tb_1.tid = Tb_2.tidset tb_1.tcontent = tb_2.tcontent

The following is a practical example of writing a link to a phpcms generated static page to the URL field in the Phpcms_content table:

Let's put together the required URL field columns.

SELECT CONCAT (From_unixtime (inputtime, '%y/%m%d '), '/', ContentID, '. html ') as DT from Phpcms_content ORDER by ContentID DE Sc

Then, in the Query Editor (navicat), copy the entire segment to the URL column in the Phpcms_content table.

MySQL field to copy table fields to other tables

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.