Thank You. I am not sure which one is faster because I don't have any HUGE tables to test it on, but someone from the PHP mailing list gave me the following that works like a charm.
create table table2 select * from table1

Thanks
Steve

At 02:09 PM 11/20/2002 -0500, you wrote:
On 20 Nov 2002, at 12:54, Steve Buehler wrote:

> What I am trying to do is to copy a mysql table to a new
> table name in a PHP script.

Use the query "SHOW CREATE TABLE $from_table" to get the SQL
statement for creating the table, then do

        $create_table_sql = preg_replace(
                '/^CREATE TABLE `[^`]+`/',
                "CREATE TABLE $to_table",
                $create_table_sql
        );

to modify the SQL to create the new table.  Execute the query to
create the empty table.  To fill it, simply do

    INSERT INTO $to_table SELECT * FROM $from_table

--
Keith C. Ivey <[EMAIL PROTECTED]>
Tobacco Documents Online
http://tobaccodocuments.org
Phone 202-667-6653

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3


---------------------------------------------------------------------
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to