0

I have two tables (campaigns and old_campaigns) in a MySQL database.

Both tables have identical columns: id, user_id, url, ordered, sent, start_date, end_date.

The columns ordered and sent are both integers. Here's what I want to do:

I want to check to see if the number in the sent column is 1.25x higher than the number in the ordered column. If it is, I want to move that row from that row from the campaigns to old_campaigns table.

For example, if ordered was 100, then if sent was 125+, that row should be moved.

I'm technically already doing this with PHP, I'm really just looking to see if there's a way to do this with pure MySQL and move all the rows at the same time, since my PHP script is currently having to loop through each row and check.

Andrew
  • 665
  • 2
  • 8
  • 11
  • where ordered* 1.25 < sent – degr Dec 30 '16 at 07:23
  • 1
    `INSERT INTO campaigns SELECT * from old_campaigns where sent>1.25*ordered` – Quicksilver Dec 30 '16 at 07:25
  • http://stackoverflow.com/questions/5420156/mysql-move-row-between-tables http://stackoverflow.com/questions/19821736/mysql-move-rows-from-one-table-to-another http://stackoverflow.com/questions/5420156/mysql-move-row-between-tables – R.K.Bhardwaj Dec 30 '16 at 07:42

0 Answers0