Ask for a MySQL basic question. Copy a record of ID a into the same table, generate a new record, modify the value of some fields in the process, how to write

Source: Internet
Author: User
Ask for a basic MySQL problem.:( PHP) copy a record with ID A into the same table, generate a new record, modify the values of some fields in the process, how to write?
This is the case:
The user copies an already published item and then publishes it as part of the change.

Only content that is likely to be modified is submitted at the time of publication, and other content is obtained from the database directly based on the ID of the copied record

Ask the SQL statement how to write online do not know how to search .... MySQL PHP Enquiry Copy


------Solution--------------------
The format is as follows
INSERT into user_list (username, ' password ', ' status ') SELECT ' asfasfasf ', ' Password ', ' status ' from User_list WHERE id=2


Red Part originally is username, if do not want id=2 username, change to ASFASFASF can
------Solution--------------------
References: The
format is as follows
INSERT into user_list (username, ' password ', ' status ') SELECT ' asfasfasf ', ' Password ', ' status ' from User_list WHERE id=2


Red Part originally is username, if do not want id=2 username, change to ASFASFASF can
...

++
Change the SQL statement to what you want to change.
------Solution--------------------
Using SQL statements
Insert into table (field) Select field from table condition
  • 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.