Copying a row

2003-08-21 Thread Ville Mattila
Hi everyone,

Is there any easy way to duplicate a row in a table with auto increment
column, that shouldn't of course be copied. I tried a query NSERT INTO
table SELECT * FROM table but it caused an error due to the auto
increment column. I succeeded with listing all required fields in the
query, but it's not very efficient way to do it (in my opinion) as when I
modify the table (add or remove columns), I should modify also all
queries.

Any help is appreciated.

Thanks,
Ville

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



copying a row

2003-01-30 Thread W. Enserink
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?

regards Wilbert



- 
Pas de Deux 
Van Mierisstraat 25 
2526 NM Den Haag 
tel 070 4450855 
fax 070 4450852 
http://www.pdd.nl 
[EMAIL PROTECTED] 
-

-
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




copying a row

2003-01-30 Thread W. Enserink
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?

regards Wilbert

- 
Pas de Deux 
Van Mierisstraat 25 
2526 NM Den Haag 
tel 070 4450855 
fax 070 4450852 
http://www.pdd.nl 
[EMAIL PROTECTED] 
-

-
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




Re: copying a row

2003-01-30 Thread Gelu Gogancea
Hi
- Original Message -
From: W. Enserink [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, January 30, 2003 4:34 PM
Subject: copying a row


 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?
It should work something like :
set @a:='';
set @b:=''

set @n:='';
set a variable for each item which you need to insert in to table.
select @a:=ITEM1,@b:=ITEM2...@n:ITEMn from your_table where.
insert into your_table values(@a,@b@n)

Regards,

Gelu

 regards Wilbert



 -
 Pas de Deux
 Van Mierisstraat 25
 2526 NM Den Haag
 tel 070 4450855
 fax 070 4450852
 http://www.pdd.nl
 [EMAIL PROTECTED]
 -

 -
 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




-
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




Re: copying a row

2003-01-30 Thread Zak Greant
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