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 8440475
In Process

The Archive Base Latest Questions

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

I am trying to implement a webservice that will take as input some ingredients,

  • 0

I am trying to implement a webservice that will take as input some ingredients, it will look up some recipies in a database and will return those ones that require all or some of the ingredients provided as input.

I can easily figure out the many to many relationship between the recipies and ingrdients so I am planning to have a table for recipies, one for ingredients and a link table in the middle. However, if I do this I am not sure how I can query the tables in an efficient way to get the information required.

To give an explicit example consider the following:

Input: Pasta, Chicken, Pesto, Tomatoes
Output should be:

  • Pasta with Chicken in Tomato sauce (requiring Pasta, Chicken and tomatoes)
  • Pasta with Pesto in the oven (requiring Pasta and Pesto)
  • etc.

But output should not include Chicken with potatoes in tomato sause (since we do not have potatoes in the input ingredients).

I will be implementing this in Java and MySQL (although the Java part is probably not important for this question).

Can somebidy help me in approaching this. I am really after how to implement the Query but if you can think of other ways to approach it then these are welcome too.

Thanks in advance

  • 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-10T08:18:18+00:00Added an answer on June 10, 2026 at 8:18 am

    First, put your list of ingredients that are “desired” into a temporary table. Let’s call this “desired”.

    The following query will find recipes that have only ingredients in the desired table:

    select r.recipe.name, group_concat(i.ingredientname separator ', ') as ingredients,
           count(*) as numingredients
    from RecipeIngredient ri join
         Recipe r
         on ri.recipeid = r.recipeid join
         Ingredient i
         on ri.ingredientid = i.ingredientid left outer join
         Desired d
         on i.ingredientname = d.ingredientname
    group by r.recipe.name
    having max(case when d.ingredientname is null then 1 else 0 end) = 0 -- all ingredients in list
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a web service that uses open JPA to access
I’m trying to implement a SOAP webservice in Python 2.6 using the suds library.
My company is planning to implement a solution in multiple applications that will help
I am trying to call a webservice using WCF that uses the following encoding:
I am trying to implement a MVC application that has a view, controller and
I'm trying to make a WCF service that will work with JSON-P (long-story short,
I need to implement a project that will consume XML Web Service from other
I am trying to develop an android application that will use the same MySQL
I'm trying to create a generic web service that will always respond with OK,
I'm trying to ammend an existing SOAP Webservice that uses Spring-WS and JAXB on

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.