Insert into Select From Delete – Mysql

Mar 12, 2012   //   by phpfreelancer.biz   //   Blog, MySQL Tutorial  //  No Comments

I want to transfer 50 rows from table1 to table 2, how should I do this?

Here’s the Code:


START TRANSACTION ;

INSERT INTO table2 
  SELECT * 
  FROM table1 
  WHERE uid IN ('23','34','345','567','3242','34322','2') ;

DELETE FROM table1 
WHERE uid IN ('23','34','345','567','3242','34322','2') ;

COMMIT ;

Leave a comment

Share This Post

RSS Wordpress News