On Thu, Jan 30, 2003 at 04:13:17PM +0100, W. Enserink wrote:
> Hi all,
> 
> 
> Im in need of some tps.
> 
> I want to copy a row in a table to a new row in the same table except for
> the unique ID. Is there some mysql statement for this?

  Dear Wilbert,

  INSERT ... SELECT almost allows you to do this, however you cannot
  select from the same table that you are inserting into.

  You will need to do something like this:

  CREATE TEMPORARY TABLE temp 
         SELECT field_1, field_2, field_3 FROM table
                 WHERE field_1 > 100;

  INSERT table (field_1, field_2, field_3) 
         SELECT (field_1, field_2, field_3) FROM temp;

  DROP TABLE temp;

Cheers!
-- 
 Zak Greant <[EMAIL PROTECTED]> | MySQL Advocate |  http://zak.fooassociates.com

Using and Managing MySQL
  MySQL Training: Hamburg, March 24-28, 2003
  Visit http://mysql.com/training for more information

"Gosh, Batman. The nobility of the almost-human porpoise."
                                                      --Robin, the Boy Wonder

---------------------------------------------------------------------
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