473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Duplicating records...

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
Jul 23 '05 #1
4 1529
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
Jul 23 '05 #2
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" <jg******@verizon.net> wrote in message
news:5uT2e.3$7b.2@trndny02...
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

Jul 23 '05 #3
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
Jul 23 '05 #4
Felix - good grief yes that's right. thank you very much!

Jon

"Felix Geerinckx" <fe*************@gmail.com> wrote in message
news:xn***************@news.easynews.com...
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

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Karam Chand | last post by:
Greetings I manage a website wherein i keep track of the people email who have downloaded my software and the version number. the structure is like - id int auto_increment primary key,...
1
by: pwys | last post by:
Hello to everyone WOndering if there anyone could help me with this. I have a Primary & a secondary table with the unique key (InvoiceNo) Waht i want is to make duplicate copy of a selected...
7
by: Paolo | last post by:
I know I should not be doing this, but I find it very useful. I have a database in Access which stores data for a small company. Sometimes we need to add similar information to different tables....
6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
8
by: Josetta | last post by:
I have found a wealth of information here on how to duplicate records in forms with subforms. I have adapted code found here to work with my forms. It works beautifully the first time I hit the...
0
by: rmli | last post by:
Duplicating a Database using RMAN http://quickdba.blogspot.com/2006/05/duplicating-database-using-rman_22.html
2
by: kkiger | last post by:
My problem is this, I can set up a command button to duplicate a record everytime I click on it. What happens is that I get a record but it will be at the end of the table. For example, if I am on...
7
by: Albennett | last post by:
Hello. I’m new to writing VBA code but getting there thanks, for the most part, to the excellent advice on this site. I trying to create the code which will allow all records from a subform to...
2
by: zandiT | last post by:
hello i created a database that has a form which represents a template. this template is filled out every month. my problem is i don't want to have to copy and paste ever record wen the template is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.