Re: Re: moving a selection of records from one table to another (identical in structure) table?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

> Would you happen to have a nice little example-script for me/us?  :-)

yup, here's a little example:

    $condition = "WHERE username LIKE 'm%'"
    if (mysql_query("INSERT AuthCopy SELECT * FROM Auth $condition"))
        mysql_query("DELETE FROM Auth $condition");

This assumes the two tables are identical with regard to column
order/type but not name, and that you want to copy and remove the data
from the first table.
The whole operation is performed by the MySQL server, so requires almost
zero processing by PHP and should be faster.  However, it also means you
don't get to verify each insert as it is made, but that should not be a
major problem.


Niel

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux