473,671 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1537
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******@veriz on.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.ea synews.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
1320
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, email char,
1
367
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 invoice no (both Primary & secondary) into a new invoice no. can some one help me in this?
7
2096
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. Currently I am already doing something similar by copying certain records into the same table. The only thing that changes is one field. Please look at the code: Dim MyDb As DAO.Database, MyRs As DAO.Recordset Dim strCode As String
6
2499
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 products). Tables: tblCategoryDetails CategoryID SpecID
8
5759
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 "duplicate" button. It copies the main form data, the subform data and moves to the new record. Great! Here's the problem...if I move to another record (or stay on the newly created record, for that matter), and hit the Duplicate button...
0
1062
by: rmli | last post by:
Duplicating a Database using RMAN http://quickdba.blogspot.com/2006/05/duplicating-database-using-rman_22.html
2
1171
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 record 5 of 10 records and I click on my button I get a new record as number 11, I want the record to be number 6, inserted after the record I click on. I need to have the records in order because the next step is to generate a new number for the...
7
2047
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 be copied and duplicated back in the original underlying table for that subform. To give a bit more background, the main form contains records of individual ‘reports’ (held in table called CPG1) and the subform (CPG3_Subform) identifies the...
2
1261
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 being filled out the next month. i thought of putting the controls i want to duplicate in a label, but the text is too much and i can't scroll with a label control, so had to use a text/ memo box. is there a way i can click a button and the...
0
8485
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8403
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8605
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.