Re: Re: moving a selection of records from one table to another (identical in structure) table?
| From: | Niel Archer | Date: | Wed, 27 Sep 2006 12:58:52 +0000 |
| Subject: | Re: Re: moving a selection of records from one table to another (identical in structure) table? | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42416@lists.php.net to get a copy of this message | ||
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