Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9106487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:21:10+00:00 2026-06-17T02:21:10+00:00

this is my scenario: I have a table that holds recipes, and another that

  • 0

this is my scenario: I have a table that holds recipes, and another that holds ingredients linked to a recipe (recipe_ingredients).

TABLE RECIPE_INGREDIENTS:

ID      RECIPE_ID     INGREDIENT_ID
1           1              6
2           2              3
3           2              4

in my case, I want to return all recipes with some ingredients introduced by user (could be one or more), in this example let’s say all recipes with ingredients 3 and 4. Obviusly when I only query for one ingredient there’s no problem, but I don’t know how achieve that with more than one…
Thanks all in advance! any advice is welcome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:21:11+00:00Added an answer on June 17, 2026 at 2:21 am

    It sounds like you want this:

    select RECIPE_ID
    from RECIPE_INGREDIENTS
    where INGREDIENT_ID in (3, 4)
    group by RECIPE_ID
    having count(distinct INGREDIENT_ID ) >=2
    

    See SQL Fiddle with Demo

    Then if you want to join this to you recipe table:

    select r.*
    from recipes r
    inner join
    (
      select RECIPE_ID
      from RECIPE_INGREDIENTS
      where INGREDIENT_ID in (3, 4)
      group by RECIPE_ID
      having count(distinct INGREDIENT_ID ) >=2
    ) ri
      on r.RECIPE_ID = ri.RECIPE_ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this scenario i have a staging table that contains all the record
This is my scenario: I have a table that contains events, every event has
I have this scenario: I have a mysql database, with a table that contain
The architecture for this scenario is as follows: I have a table of items
Consider this scenario. I have my own website, that I use as my identifier,
I think this is a pretty common scenario: I have a webpage that's returning
Here is the scenario: I have a table that records the user_id, the module_id,
Scenario : i have a database table that is being updated frequently by some
I have the following scenario, using mvc3: I have a database table which holds
Here's some easy reputation for someone. The scenario I have a table that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.