MySQL Forums
Forum List  »  Newbie

Re: why not work?
Posted by: Felix Geerinckx
Date: April 07, 2005 05:15AM

gianpaolo fabiani wrote:

> How can I duplicate record in the same table with
> only a new id?

With the following table definition:

mysql> desc templ;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| f1 | varchar(100) | YES | | NULL | |
| f2 | varchar(100) | YES | | NULL | |
+-------+--------------+------+-----+---------+----------------+

you can do the following:

INSERT INTO templ (id, f1, f2)
SELECT NULL, f1, f2
FROM templ
WHERE id= <<some_id>>;

--
felix

Options: ReplyQuote


Subject
Written By
Posted
April 07, 2005 02:40AM
Re: why not work?
April 07, 2005 05:15AM
April 08, 2005 01:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.