Tuesday, July 25, 2017

More SQL


use Cafe

Select * from Diets

Insert into Recipe(RecipeName, RecipeInstructions, 
RecipeTimeMinutes, Component)
Values('Cheese Sandwhich',
'Add Cheese to bread and grill in butter',
5,0)

Select * from Recipe
Select * from Inventory
Select * from Ingredient
Select * from RecipeIngredient

Delete From Ingredient where IngredientID > 10

Insert into Inventory(InventoryName, Cost, VenderID, Expiration)
Values('Bread',4.32,1,'7/30/2017'),
('cheese',12.50,1,'9/30/2017')

Insert into Ingredient(Units, Name, InventoryID)
Values('slice', 'bread',5),
('slice','Cheddar',6)

Insert into RecipeIngredient(RecipeID, IngredientID, Amount)
Values(2,5,2),
(2,6,1)
Update RecipeIngredient 
Set IngredientID=9
where RecipeID=2 and amount=2

Update RecipeIngredient
Set IngredientID=10
where RecipeID=2 and amount=1



Select RecipeName, RecipeInstructions, RecipeTimeMinutes,
 name as Ingredient, Amount
 From Recipe
 inner join RecipeIngredient
 on Recipe.RecipeID=RecipeIngredient.RecipeID
 inner join Ingredient
 on Ingredient.IngredientID=RecipeIngredient.IngredientID
 Where Recipe.recipeName='cheese sandwhich'




No comments:

Post a Comment