MySQL inserts the data queried in Table a into Table B.

Source: Internet
Author: User
MySQL inserts the data queried in Table a into Table B if Table B has 1codeclasssqlcodeclasssqlcodeclasssqlinsertintobselect * froma; codecodecode if Table B does not have 1 partition

MySQL inserts the data queried in Table a into Table B. If table B has 1 code class = sqlcode class = sqlinsert into B select * from; /code if Table B does not exist 1 code class = sqlcode class = sqlc

MySQL inserts the data queried in Table a into Table B.

If table B exists

1

insert into b select * from a;

If table B does not exist

1

create table b as select * from a;

Extension:

Insert a write segment value in Table B to Table.

1

insert into a (userID,userName) select b.userID,b.userName from tr_ajax_chat_messages;

Save the userID values of table a and table B to Table.

1update a set a.userName=(select b.userName from b where a.userID = b.userID);

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.