insert data from one table to another in mysql

后端 未结 10 534
深忆病人
深忆病人 2020-11-29 18:39

i want to read all data from one table and insert some data in to another table. my query is

  INSERT INTO mt_magazine_subscription ( 
      magazine_subscr         


        
10条回答
  •  清酒与你
    2020-11-29 19:21

    You can use INSERT...SELECT syntax. Note that you can quote '1' directly in the SELECT part.

    INSERT INTO mt_magazine_subscription ( 
          magazine_subscription_id, 
          subscription_name, 
          magazine_id, 
          status ) 
    SELECT magazine_subscription_id, 
           subscription_name, 
           magazine_id, 
           '1'
    FROM tbl_magazine_subscription
    ORDER BY magazine_subscription_id ASC 
    

提交回复
热议问题