RE: How to duplicate records

2002-06-20 Thread Richard DeWath

Just a thought on something I was reading with temp tables:

1.  extract the records you want to change the date on from your existing 
table to a temp table.
2.  update the date in the temp table
3.  insert the new records back into the original table.

This avoids the csv extract and changing then reinserting.

R.D.

--On Thursday, June 20, 2002 11:32:22 AM -0400 Adam Nelson 
[EMAIL PROTECTED] wrote:

 I have looked at this problem before and I honestly think there is not a
 proper way to do it within mysql.  The only ways are cut  paste,
 programmatically, or subselects (slated for 4.1?).

 -Original Message-
 From: Carlos Fernando Scheidecker Antunes [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 18, 2002 2:40 PM
 To: Don Vu
 Cc: MySQL List
 Subject: Re: How to duplicate records


 Don,

 Thank you very much.

 The only problem is that the primary index Code, Model and Year and what
 I
 need is to duplicate the Code, Model and Units for a different year,
 2003,
 that does not exist. If I do the statement bellow it won't work. What I
 need
 is to insert Code, Model, Units for a specific code match but they have
 to
 be duplicated for year 2003.

 Thanks again,

 C.F.



 - Original Message -
 From: Don Vu [EMAIL PROTECTED]
 To: Carlos Fernando Scheidecker Antunes [EMAIL PROTECTED]; MySQL
 List [EMAIL PROTECTED]
 Sent: Tuesday, June 18, 2002 9:38 AM
 Subject: RE: How to duplicate records


 mabye an insert into...select will work, something like:

 INSERT INTO new tablename
 SELECT Code, Model, Units
 from original table
 where Year=2003
 and ((Code = 'N200') or (Code='N205'));

 http://www.mysql.com/doc/I/N/INSERT_SELECT.html

 -Don

 -Original Message-
 From: Carlos Fernando Scheidecker Antunes
 [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 18, 2002 10:25 AM
 To: MySQL List
 Subject: How to duplicate records
 Importance: High


 Hello all,

 I've got some records of a Database that I would like to duplicate if
 possible with an statement.

 The table has Code, Model, Year, units. The primary key is Code, Model
 and
 Year. What I need is to duplicate Code, Model and units for a
 different
 year.

 Say I want to duplicate all records which Code are N200 and N205 with
 the
 same model and same units but for year 2003.

 Is there any select and insert/replace statement to acomplish this?

 There are about 3.000 records and doing that manually is impossible. I
 am
 considering dump the whole file to a .csv and change year to 2003 and
 then
 reinsert it.

 Is there any way to do it in a smart way? Meaning an SQL statement.

 Thank you,

 Carlos Fernando.


 -
 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



 -
 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






Richard DeWath
System Administrator
E.L. and Associates
[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: How to duplicate records

2002-06-20 Thread Keith C. Ivey

On 20 Jun 2002, at 11:35, Richard DeWath wrote:

 Just a thought on something I was reading with temp tables:
 
 1.  extract the records you want to change the date on from your existing 
 table to a temp table.
 2.  update the date in the temp table
 3.  insert the new records back into the original table.
 
 This avoids the csv extract and changing then reinserting.

You don't need a separate step to update the date.  When extracting 
the records into the temporary table, just change SELECT Code, 
Model, Units, Year to SELECT Code, Model, Units, 2003 in your SQL.

-- 
Keith C. Ivey [EMAIL PROTECTED]
Tobacco Documents Online
http://tobaccodocuments.org

-
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




How to duplicate records

2002-06-18 Thread Carlos Fernando Scheidecker Antunes

Hello all,

I've got some records of a Database that I would like to duplicate if
possible with an statement.

The table has Code, Model, Year, units. The primary key is Code, Model and
Year. What I need is to duplicate Code, Model and units for a different
year.

Say I want to duplicate all records which Code are N200 and N205 with the
same model and same units but for year 2003.

Is there any select and insert/replace statement to acomplish this?

There are about 3.000 records and doing that manually is impossible. I am
considering dump the whole file to a .csv and change year to 2003 and then
reinsert it.

Is there any way to do it in a smart way? Meaning an SQL statement.

Thank you,

Carlos Fernando.


-
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: How to duplicate records

2002-06-18 Thread Egor Egorov

Carlos,
Tuesday, June 18, 2002, 5:24:48 PM, you wrote:

CFSA I've got some records of a Database that I would like to duplicate if
CFSA possible with an statement.

CFSA The table has Code, Model, Year, units. The primary key is Code, Model and
CFSA Year. What I need is to duplicate Code, Model and units for a different
CFSA year.

CFSA Say I want to duplicate all records which Code are N200 and N205 with the
CFSA same model and same units but for year 2003.

CFSA Is there any select and insert/replace statement to acomplish this?

CFSA There are about 3.000 records and doing that manually is impossible. I am
CFSA considering dump the whole file to a .csv and change year to 2003 and then
CFSA reinsert it.

CFSA Is there any way to do it in a smart way? Meaning an SQL statement.

You can't do it with one SQL statement. MySQL has INSERT .. SELECT and
REPLACe .. SELECT statements but you can't retrieve data from the same
table into which you are inserting. What about inserting necessary
data into temporary table and than upload them into your table?

You can find info about INSERT .. SELECT and REPLACE .. SELECT at:
http://www.mysql.com/doc/I/N/INSERT_SELECT.html
http://www.mysql.com/doc/R/E/REPLACE.html

CFSA Thank you,
CFSA Carlos Fernando.





-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com



-
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: How to duplicate records

2002-06-18 Thread Don Vu

mabye an insert into...select will work, something like:

INSERT INTO new tablename 
SELECT Code, Model, Units 
from original table 
where Year=2003
and ((Code = 'N200') or (Code='N205'));

http://www.mysql.com/doc/I/N/INSERT_SELECT.html

-Don

-Original Message-
From: Carlos Fernando Scheidecker Antunes [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 18, 2002 10:25 AM
To: MySQL List
Subject: How to duplicate records
Importance: High


Hello all,

I've got some records of a Database that I would like to duplicate if
possible with an statement.

The table has Code, Model, Year, units. The primary key is Code, Model and
Year. What I need is to duplicate Code, Model and units for a different
year.

Say I want to duplicate all records which Code are N200 and N205 with the
same model and same units but for year 2003.

Is there any select and insert/replace statement to acomplish this?

There are about 3.000 records and doing that manually is impossible. I am
considering dump the whole file to a .csv and change year to 2003 and then
reinsert it.

Is there any way to do it in a smart way? Meaning an SQL statement.

Thank you,

Carlos Fernando.


-
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: How to duplicate records

2002-06-18 Thread Carlos Fernando Scheidecker Antunes

Don,

Thank you very much.

The only problem is that the primary index Code, Model and Year and what I
need is to duplicate the Code, Model and Units for a different year, 2003,
that does not exist. If I do the statement bellow it won't work. What I need
is to insert Code, Model, Units for a specific code match but they have to
be duplicated for year 2003.

Thanks again,

C.F.



- Original Message -
From: Don Vu [EMAIL PROTECTED]
To: Carlos Fernando Scheidecker Antunes [EMAIL PROTECTED]; MySQL
List [EMAIL PROTECTED]
Sent: Tuesday, June 18, 2002 9:38 AM
Subject: RE: How to duplicate records


 mabye an insert into...select will work, something like:

 INSERT INTO new tablename
 SELECT Code, Model, Units
 from original table
 where Year=2003
 and ((Code = 'N200') or (Code='N205'));

 http://www.mysql.com/doc/I/N/INSERT_SELECT.html

 -Don

 -Original Message-
 From: Carlos Fernando Scheidecker Antunes [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 18, 2002 10:25 AM
 To: MySQL List
 Subject: How to duplicate records
 Importance: High


 Hello all,

 I've got some records of a Database that I would like to duplicate if
 possible with an statement.

 The table has Code, Model, Year, units. The primary key is Code, Model and
 Year. What I need is to duplicate Code, Model and units for a different
 year.

 Say I want to duplicate all records which Code are N200 and N205 with the
 same model and same units but for year 2003.

 Is there any select and insert/replace statement to acomplish this?

 There are about 3.000 records and doing that manually is impossible. I am
 considering dump the whole file to a .csv and change year to 2003 and then
 reinsert it.

 Is there any way to do it in a smart way? Meaning an SQL statement.

 Thank you,

 Carlos Fernando.


 -
 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


-
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