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

  • Home
  • SEARCH
  • 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 8096287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:24:18+00:00 2026-06-05T21:24:18+00:00

Right now I am using sqlite within a ios application, and I want to

  • 0

Right now I am using sqlite within a ios application, and I want to be able to search for recipes that can be made from a list of ingredients (ie recipes such that are a subset of the provided ingredients)

For example:

Recipe 1: A B C
Recipe 2: A B
Recipe 3: C D
Recipe 4: A
Recipe 5: E

Query for ingredients A B C returns recipes {1, 2, 4}
Query for ingredients A B returns recipes {2, 4}
Query for ingredients D returns {}

Currently what I have set up is

Table Items
name text primary key

Table Recipes
ID required_item integer, recipe_name text

I can easily do queries for recipes containing any of the three ingredients and queries for recipes containing all of the three ingredients, but I haven’t been able to figure out how to do queries for only

Recipes ∈ P(Ingredients)

Sorry, I’m new to database programming, and any help would be greatly appreciated

  • 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-05T21:24:19+00:00Added an answer on June 5, 2026 at 9:24 pm

    You could use a left join to a search table. Then group by recipe. Use a having clause to demand that for each recipe, there are no ingredients that are not in the search list. For example:

    select  ri.RecipeNr
    from    RecipeIngredients ri
    left join
            (
            select  'A' as Ingredient
            union all
            select  'B'
            union all
            select  'C'
            ) search
    on      ri.Ingredient = search.Ingredient
    group by
            ri.RecipeNr
    having  count(case when search.Ingredient is null then 1 end) = 0
    

    Live example at SQL Fiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using a Java EE application and we are right now using Informix
Right now I'm using a few scripts to generate files that I'm including as
I'm in the process of designing an Android application right now. I understand SQLite
Right now using SQLite i write the below (I may move to either mysql
Right now I am using a custom list view and I am inflating an
Right now I am using std::pair to represent a 2d point in c++. However,
Right now I currently using transactional replication with updatable subscription. Is there any ways
Right now I'm using the following: export CFLAGS=-O2-isysroot/Developer/SDKs/MacOSX10.5.sdk -arch i386 -I/sw/include/ export LDFLAGS=-Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk,-L/sw/lib/ sudo
Right now I'm using JFreeChart in order to create a dynamic chart. However the
Right now I'm using: r.forEach( function (el) { el.scale(0.5, 0.5, 0.0, 0.0); }); to

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.