Re: Populating one table with data from another

2003-01-14 Thread Stefan Hinz, iConnect \(Berlin\)
Michael,

> I have a table, products containing a 944 rows. One of the fields is
> fgNumber,
> I have another table, categoryRelatedToProducts which also has an
fgNumber
> field and currently has no data.
> I'd like to add all 944 fgNumbers to the categoryRelatedToProducts
table.

INSERT INTO categoryRelatedToProducts /* great table name ;-) */
(categoryRelatedToProducts.fgNumber) SELECT products.fgNumber FROM
products;

is what you might want to do.

Regards,
--
  Stefan Hinz <[EMAIL PROTECTED]>
  Geschäftsführer / CEO iConnect GmbH <http://iConnect.de>
  Heesestr. 6, 12169 Berlin (Germany)
  Tel: +49 30 7970948-0  Fax: +49 30 7970948-3

- Original Message -
From: "Michael Knauf/Niles" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 14, 2003 6:01 PM
Subject: Populating one table with data from another


>
> Ok, this has got to be easy, but I'm not getting it right...
>
>
> I have a table, products containing a 944 rows. One of the fields is
> fgNumber,
>
> I have another table, categoryRelatedToProducts which also has an
fgNumber
> field and currently has no data.
>
> I'd like to add all 944 fgNumbers to the categoryRelatedToProducts
table.
>
> Can I do this with one sql statement?
>
> Michael
>
>
>
> -
> 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: Populating one table with data from another

2003-01-14 Thread Gelu Gogancea
Hi,
You can use INSERT...SELECT.
Regards,

Gelu
_
G.NET SOFTWARE COMPANY

Permanent e-mail address : [EMAIL PROTECTED]
  [EMAIL PROTECTED]
- Original Message -
From: "Michael Knauf/Niles" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 14, 2003 7:01 PM
Subject: Populating one table with data from another


>
> Ok, this has got to be easy, but I'm not getting it right...
>
>
> I have a table, products containing a 944 rows. One of the fields is
> fgNumber,
>
> I have another table, categoryRelatedToProducts which also has an fgNumber
> field and currently has no data.
>
> I'd like to add all 944 fgNumbers to the categoryRelatedToProducts table.
>
> Can I do this with one sql statement?
>
> Michael
>
>
>
> -
> 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




Populating one table with data from another

2003-01-14 Thread Michael Knauf/Niles

Ok, this has got to be easy, but I'm not getting it right...


I have a table, products containing a 944 rows. One of the fields is
fgNumber,

I have another table, categoryRelatedToProducts which also has an fgNumber
field and currently has no data.

I'd like to add all 944 fgNumbers to the categoryRelatedToProducts table.

Can I do this with one sql statement?

Michael



-
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: Populating one table with data from another

2003-01-14 Thread Steve Edberg
Use INSERT...SELECT syntax:

	http://www.mysql.com/doc/en/INSERT_SELECT.html

-steve


At 12:01 PM -0500 1/14/03, Michael Knauf/Niles wrote:

Ok, this has got to be easy, but I'm not getting it right...


I have a table, products containing a 944 rows. One of the fields is
fgNumber,

I have another table, categoryRelatedToProducts which also has an fgNumber
field and currently has no data.

I'd like to add all 944 fgNumbers to the categoryRelatedToProducts table.

Can I do this with one sql statement?

Michael




--
++
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
++
| SETI@Home: 1001 Work units on 23 oct 2002  |
| 3.152 years CPU time, 3.142 years SETI user... and STILL no aliens...  |
++

-
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: Populating one table with data from another

2003-01-14 Thread Paul DuBois
At 12:01 -0500 1/14/03, Michael Knauf/Niles wrote:

Ok, this has got to be easy, but I'm not getting it right...


I have a table, products containing a 944 rows. One of the fields is
fgNumber,

I have another table, categoryRelatedToProducts which also has an fgNumber
field and currently has no data.

I'd like to add all 944 fgNumbers to the categoryRelatedToProducts table.

Can I do this with one sql statement?


Just that column?

INSERT INTO categoryRelatedToProducts (fgNumbers)
SELECT fgNumbers FROM products;




Michael



-
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