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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:17:31+00:00 2026-06-15T10:17:31+00:00

I have two tables in my SQLLite database. I am trying to get back

  • 0

I have two tables in my SQLLite database. I am trying to get back the drinks that can be made with the ingredients typed in.

I am trying to formulate this query to get what I want.

Table Drinks

Columns

drink_id | title | ingredients | directions | ingredientsNum

Sample row looks like

1 | Papa Smurf | 1 crushed blue popsicle, 8 oz Kool-Aid , 4 oz vodka | The directions | 3

Table Ingredients

Columns

drink_id | ingredient

Sample row looks like

1 | blue popsicle

My Query at the moment

This is my partial pseudocode at what I want to return (after I get this I’ll dynamically put in terms to query).

I want to return all drinks that have the amount of inputs to be equal to or more than the drinks ingredient number, and those inputted ingredients match all the ingredients needed in the drink.

SELECT drinks.title, drinks.ingredients, drinks.directions
FROM drinks, (SELECT count(ingredients._id) as ingredientNumber FROM ingredients
WHERE ingredients.ingredient LIKE '%rum%'
GROUP BY ingredients._id) as foundIngredients
WHERE drinks.ingredientsNum = foundIngredients.ingredientNumber;

Can anybody help me towards getting the best suited query or even giving me some hints on restructuring my database model? I just made this database from a long JSON file of 80k lines.

  • 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-15T10:17:32+00:00Added an answer on June 15, 2026 at 10:17 am

    Query reflecting clarified question:

    SELECT drinks.title, drinks.ingredients, drinks.directions
    FROM drinks
    WHERE drinks.ingredientsNum = (
        SELECT count(*)
        FROM ingredients
        WHERE (
            ingredients.ingredient LIKE '%rum%'
            OR ingredients.ingredient LIKE '%coke%'
            OR ingredients.ingredient LIKE '%vodka%'
            -- the same goes for each ingredient
        )
        AND ingredients.drink_id = drinks.drink_id
    )
    

    Similarly, if you allow a drink to have extra ingredients besides all specified:

    SELECT drinks.title, drinks.ingredients, drinks.directions
    FROM drinks
    WHERE drinks.ingredientsNum >= [number of input ingredients]
    AND [number of input ingredients] <= (
        SELECT count(*)
        FROM ingredients
        WHERE (
            ingredients.ingredient LIKE '%rum%'
            OR ingredients.ingredient LIKE '%coke%'
            OR ingredients.ingredient LIKE '%vodka%'
            -- the same goes for each ingredient
        )
        AND ingredients.drink_id = drinks.drink_id
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I have an Android project that has a database with two tables: tbl_question
I have two tables in my MySQL database, one is a library of all
I have two tables in a database, one lists package and one lists dependencies:
I have two table views displaying the data from a Sqlite database. I can
I'm trying to run an NHibernate over sqlite. i have two projects: 1. Orange.Database
Let's say I have a database with two tables Persons and PhoneNumbers , where
I am trying to create two tables within the same sqlite database. Now, this
I have a database manager class where i build a table that has two
I'm working with the Android SQLite Database and I have two Tables in it.
I have a SQLITE database with two tables. Table A has an integer timestamp

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.