|
Home > Archive > MySQL Server Forum > March 2005 > Duplicating records...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Duplicating records...
|
|
| Jon Cooper 2005-03-31, 7:01 am |
| I have looked long n hard at the Insert Select as being the answer to my
need to create duplicate records. (Purpose is basically to allow someone to
create a duplicate of an existing email template then modify it). I have
tried all sorts of variations on:
INSERT INTO emaillist SELECT * FROM emaillist WHERE emailid = #url.emailid#
(inc trying IGNORE) but of course this throws an error over duplicate keys.
All I want to do is to take Record A, duplicate it and have a new key
assigned to it (the key is an autonumber field). This must be simple but I'm
stuck!
thanks
Jon
| |
| jerry gitomer 2005-03-31, 8:01 pm |
| Jon Cooper wrote:
> I have looked long n hard at the Insert Select as being the answer to my
> need to create duplicate records. (Purpose is basically to allow someone to
> create a duplicate of an existing email template then modify it). I have
> tried all sorts of variations on:
>
> INSERT INTO emaillist SELECT * FROM emaillist WHERE emailid = #url.emailid#
> (inc trying IGNORE) but of course this throws an error over duplicate keys.
>
> All I want to do is to take Record A, duplicate it and have a new key
> assigned to it (the key is an autonumber field). This must be simple but I'm
> stuck!
>
> thanks
>
> Jon
>
>
Try the following:
INSERT INTO emaillist '$keyvalue', SELECT col1, col2, col3
FROM emaillist WHERE emailid = #url.emailid#
I am not sure it will work with MySQL, but it is easy enough to
find out.
HTH
Jerry
| |
| Jon Cooper 2005-03-31, 8:01 pm |
| hi Jerry thanks for taking the time to look at this but no success!
$keyvalue' is not being recognised as a MySQL function and hunting thru the
docs I have been unable to find an equivalent.
Any other ideas massively appreciated!
Jon
"jerry gitomer" <jgitomer@verizon.net> wrote in message
news:5uT2e.3$7b.2@trndny02...
> Jon Cooper wrote:
to[color=darkred]
#url. emailid#[color=darkr
ed]
keys.[color=darkred]
I'm[color=darkred]
> Try the following:
>
> INSERT INTO emaillist '$keyvalue', SELECT col1, col2, col3
> FROM emaillist WHERE emailid = #url.emailid#
>
> I am not sure it will work with MySQL, but it is easy enough to
> find out.
>
> HTH
> Jerry
| |
| Felix Geerinckx 2005-03-31, 8:01 pm |
| On 31/03/2005, Jon Cooper wrote:
> All I want to do is to take Record A, duplicate it and have a new key
> assigned to it (the key is an autonumber field). This must be simple
> but I'm stuck!
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
| |
| Jon Cooper 2005-03-31, 8:01 pm |
| Felix - good grief yes that's right. thank you very much!
Jon
"Felix Geerinckx" <felix.geerinckx@gmail.com> wrote in message
news:xn0e0ewueghchz0
00@news.easynews.com...
> On 31/03/2005, Jon Cooper wrote:
>
>
> 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
|
|
|
|
|