newbie mySQL question

From: Westcoast Sheri (sheri_deb88_at_nospamun8nospam.com)
Date: 11/23/04


Date: Tue, 23 Nov 2004 19:13:33 GMT

I have 2 tables (table_one and table_two) that I want to combine into
one big table called "table_new."

Both tables consist of 2 columns: "fruit" and "quantity" (see my "create
table" samples below so you can understand my complex table structure
:-) Of course, table_one might have some fruits in it that table_two
doesn't have, and vice versa:

For example, here's what table_one has in it:
pomegranites 6
grapes 12
apples 9

here's what table_two has in it:
grapes 4
apples 2
bananas 5
rasberries 38

I want to combine them, so table_new ends up with:
pomegranites 6
grapes 16
apples 11
bananas 5
rasberries 38

So how can I make table_new without giving me an error on duplicate key
errors? what would be the mysql syntax to combine both tables into one
big table?

CREATE TABLE table_one (
  fruit varchar(100),
  quantity int(5),
  PRIMARY KEY (fruit),
  KEY quantity (quantity)
)

CREATE TABLE table_two (
  fruit varchar(100),
  quantity int(5),
  PRIMARY KEY (fruit),
  KEY quantity (quantity)
)

THANKS!!



Relevant Pages

  • Re: Foods that arent as good as they used to be
    ... No grapes today are worth even looking at. ... and apples and kiwifruit. ... Don't get me on the subject of exports. ... trying to plug it as a better fruit but to my taste it isn't. ...
    (rec.food.cooking)
  • Re: Fruit and Jelly
    ... I have the wife cut up our older fruit like apples, oranges, grapes and the likes and put the stuff in a cup in the unpainted birdbath for the Robins. ...
    (rec.birds)