Copy row but with new id

后端 未结 6 1030
有刺的猬
有刺的猬 2020-12-07 22:36

I have a table \"test\" with an auto incremented id and an arbitrary number of columns.

I want to make a copy of a row in this table with all columns th

6条回答
  •  心在旅途
    2020-12-07 23:04

    INSERT into table_name (  
        `product_id`, 
        `other_products_url_id`, 
        `brand`, 
        `title`, 
        `price`, 
        `category`, 
        `sub_category`, 
        `quantity`, 
        `buy_now`, 
        `buy_now_url`, 
        `is_available`, 
        `description`, 
        `image_url`, 
        `image_type`, 
        `server_image_url`, 
        `reviews`, 
        `hits`, 
        `rating`, 
        `seller_name`, 
        `seller_desc`, 
        `created_on`, 
        `modified_on`, 
        `status`) 
    SELECT 
        `product_id`, 
        `other_products_url_id`, 
        `brand`, 
        `title`, 
        `price`, 
        `category`, 
        `sub_category`, 
        `quantity`, 
        `buy_now`, 
        concat(`buy_now_url`,'','#test123456'), 
        `is_available`, 
        `description`, 
        `image_url`, 
        `image_type`, 
        `server_image_url`, 
        `reviews`, 
        `hits`, 
        `rating`, 
        `seller_name`, 
        `seller_desc`, 
        `created_on`, 
        `modified_on`, 
        `status` 
    FROM `table_name` WHERE id='YourRowID';
    

提交回复
热议问题