简体   繁体   中英

Using the Where statement in SQL

How can I Select the idR and recipeTitle if ingrDesc is "cumin" this is what I have:

  • Recipe = (idR, recipeTitle, prepText, cuisineType, mealType)
  • Ingredient = (idI, ingrDesc)
  • RecipIngr = (idR*, idI*)

     SELECT idR, recipeTitle FROM Recipe JOIN Ingredient WHERE ingrDesc='cumin' 

Without knowing your table structure, any guess would be somewhat random. Here's a random guess. I guess that Ingredient has a foreign key relating it to Recipe. I'll call that key RecipeId.

SELECT idR, recipeTitle 
FROM Recipe r
INNER JOIN Ingredient i
ON r.idR = i.RecipeId
WHERE ingrDesc='cumin'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM