MySQL Forums
Forum List  »  Newbie

Re: more then one data in one field possible?
Posted by: Phillip Ward
Date: February 12, 2014 06:19AM

Quote

now I got the foreignkey mealID correctly into table 'mealincredients' but I would have to write more then one value into the column incredientsID in table 'mealincredients'.
No, you don't.
You add a new row into mealingredient for each ingredient in each recipe:

select * from meal ; 

   +--------+ 
   | mealId | ... 
   +--------+ 
   |      1 | 
   |      2 | 
   +--------+ 

select * from ingredient ; 

   +--------------+ 
   | ingredientId | ... 
   +--------------+ 
   |           22 | 
   |           33 | 
   |           44 | 
   |           55 | 
   +--------------+ 

select * from mealIngredient ; 

   +--------+--------------+ 
   | mealId | ingredientId | ... 
   +--------+--------------+ 
   |      1 |           22 | 
   |      1 |           33 | 
   |      2 |           55 | 
   +--------+--------------+

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
Re: more then one data in one field possible?
February 12, 2014 06:19AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.