Copying from one table to another.

2001-09-12 Thread Eric Spletzer

Hello,

I'm new to MySQL, so forgive my ignorance.

I'd like to copy data from one table to another.

I have one table I've made from a filemaker database.
And one that contains my main data.

I want to update the main data from the Main file using the data from the
filemaker file.  Each row has a unique zip code, and the zip code is in each
of the files, so I thought I'd use that as an index field, but with no luck.

What I've tried so far is this, and it doesn't see to work.

Update tbl1 set CategoryInTable1 = CategoryInTable 2 where ZipInTable1 =
ZipInTable2;

I've also tried:

Update tbl1, tbl2 set CategoryInTable1 = CategoryInTable 2 where ZipInTable1
= ZipInTable2;and
Update tbl1, tbl2 set tbl1.CategoryInTable1 = tbl2.CategoryInTable 2 where
tbl1.ZipInTable1 = tbl2.ZipInTable2;

I thought to do an Insert-Select, but I can't since I want to update the
table I'm selecting from.

Any help would really be appreciated.  Thanks.

-eric spletzer


-
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




Copying table V.2.0

2001-09-12 Thread Eric Spletzer

Kevin thanks for your response.  Here are the different errors for each SQl
command I enter.

Command: update tblSNLC,tblSNOrg set
tblSNOrg.OrgSponsor1=tblSNLC.SponsorFull where tblSNOrg.OrgZip=tblSNLC.Zip;

Error:  Failed to execute SQL : SQL update tblSNLC,tblSNOrg set
tblSNOrg.OrgSponsor1=tblSNLC.SponsorFull where tblSNOrg.OrgZip=tblSNLC.Zip;
failed : You have an error in your SQL syntax near 'tblSNOrg set
tblSNOrg.OrgSponsor1=tblSNLC.SponsorFull where tblSNOrg.OrgZip=tblS' at line
1

Command:  update tblSNLC,tblSNOrg set OrgSponsor1=SponsorFull where
OrgZip=Zip;

Error:  Failed to execute SQL : SQL update tblSNLC,tblSNOrg set
OrgSponsor1=SponsorFull where OrgZip=Zip; failed : You have an error in your
SQL syntax near 'tblSNOrg set OrgSponsor1=SponsorFull where OrgZip=Zip' at
line 1


THIS NEXT ONE SEEMS THE CLOSEST
Command:  update tblSNOrg set OrgSponsor1=tblSNLC.SponsorFull where
OrgZip=tblSNLC.Zip;

Error:  
Failed to execute SQL : SQL update tblSNOrg set
OrgSponsor1=tblSNLC.SponsorFull where OrgZip=tblSNLC.Zip; failed : Unknown
table 'tblSNLC' in field list

I don't know why it wouldn't find the table

Thanks for any continued help.

-eric




On 9/12/2001 10:46 AM, Kevin Kotun [EMAIL PROTECTED] wrote:

 
 
 I obviously dont know what the error message is but
 
 Update tbl1, tbl2 set tbl1.CategoryInTable1 = tbl2.CategoryInTable 2 where
 ^
  |
 This space may be a problem
 
 good luck, 
 
 try to provide the error message
 
 -- kevin
 
 -
 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




Copying data from one table to another.

2001-09-10 Thread Eric Spletzer

Hello, I'm a newbie, so pardon my lack of wherewithal with MySQL, and thanks
for the help in advance.

I have two table and I want to copy info from one table to another.  I can
pull the correct information out with a select statement that looks
something like this

Select x1 from tbl1, tbl2 where y1 = y2

(numbers correspond to different tables)

This returns a table of the info I want to use.  Logically, what I would
like to do is:

Update tbl1 set x1 = x2 where y1 = y2;

But this won't work because x1 and x2 are from different tables, as are y1
and y2.  However, I've tried including tbl2 in the update parts, and that
doesn't work either.  I'm at a loss.

Thanks for any help.

-eric spletzer


-
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: Copying data from one table to another.

2001-09-10 Thread Eric Spletzer

Will this actually work?  Because I can't select from the table into which
I'm inserting.

Also I don't want to insert.  I want to update a bunch of records that
already exist.

Here is exactly what I want to do.

I have two tables set up that I'm dealing with right now.  One is the main
information table, and one is a table that I set up from a filemaker export.
These are tables with information about a bunch of centers our company has,
and the information I'm dealing with will be the sponsors field and the zip
code.

Basically I want to find a record in the export table, and then take the
sponsors info from that row and insert it into the sponsors slot in the
other row in the other table that correspond to the same zip code.

The code I would use is logically like this.  But it seems I can't get the
SQL right.  I do this, and it tells me it can't find my table.

Update tblOrganizations set OrgSponsors = tblCenters.CenterSponsors where
OrgZip like tblCenters. CenterZip;

Any help would really be great. Thanks.

-eric

On 9/10/2001 2:51 PM, Sheridan Saint-Michel [EMAIL PROTECTED] wrote:
 I think what you are looking for is the Insert...Select statement
 http://www.mysql.com/doc/I/N/INSERT_SELECT.html
 
 Sheridan Saint-Michel
 Website Administrator
 FoxJet, an ITW Company
 www.foxjet.com
 
 
 - Original Message -
 From: Eric Spletzer [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, September 10, 2001 4:38 PM
 Subject: Copying data from one table to another.
 
 
 Hello, I'm a newbie, so pardon my lack of wherewithal with MySQL, and
 thanks
 for the help in advance.
 
 I have two table and I want to copy info from one table to another.  I can
 pull the correct information out with a select statement that looks
 something like this
 
 Select x1 from tbl1, tbl2 where y1 = y2
 
 (numbers correspond to different tables)
 
 This returns a table of the info I want to use.  Logically, what I would
 like to do is:
 
 Update tbl1 set x1 = x2 where y1 = y2;
 
 But this won't work because x1 and x2 are from different tables, as are y1
 and y2.  However, I've tried including tbl2 in the update parts, and that
 doesn't work either.  I'm at a loss.
 
 Thanks for any help.
 
 -eric spletzer
 
 
 -
 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