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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:44:03+00:00 2026-06-12T19:44:03+00:00

This is my current setup: I have 2 tables, RECIPE and INGREDIENTS . RECIPE

  • 0

This is my current setup:
I have 2 tables, RECIPE and INGREDIENTS.
RECIPE holds the ID among other data. INGREDIENTS has X rows needed for each RECIPE.
How can one match 2 recipes with at least 2 matching ingredients?
I can do it specifying which ingredient must match, but my problem is when the recipe has more than 10 ingredients and I need two recipes that uses the same 2 ingredients, not knowing which ones.
Sorry my English, is not my natural language. I’ll post more details if needed, or if I wasn’t clear enough.

Pratical example:
Recipe 1 has: fish, potatoes and salt.
Recipe 2 has: turkey and rice.
Recipe 3 has: fish, rice and salt.
Recipe 4 has: turkey, potatoes and salt.

Result based on recipe 1 should be: 4
Result based on recipe 2 should be: None
Result based on recipe 3 should be: 1
Result based on recipe 4 should be: 1
(Yep, I need to run every recipe based on a filter not explained here)

  • 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-12T19:44:05+00:00Added an answer on June 12, 2026 at 7:44 pm

    Try something like this:

    WITH REC_ING AS (
    SELECT *
    FROM RECIPE AS T1
    INNER JOIN
    INGREDIENTS AS T2
    ON T1.ID = T2.ID)
    
    SELECT *
    FROM (
    SELECT T1.ID AS ID1, T2.ID AS ID2
    FROM REC_ING AS T1
    INNER JOIN
    REC_ING AS T2
    ON T1.INGREDIENT_ID = T2.INGREDIENT_ID 
    AND T1.ID != T2.ID) AS JOINED_TAB
    GROUP BY ID1, ID2
    HAVING COUNT(*) >= 2
    

    This is a rough copy. If it sounds like what you’re looking for, I can make a more elaborate example (incl. SQL Fiddle).

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

Sidebar

Related Questions

We have this current database which we need to replace some tables by anther
I've recently started using prettyphoto to display a video. This is my current setup
I am having a bit of difficulty with this current code I have set
As a beginner in Ocaml, I have this current working code: ... let ch_in
For some user controls, I have this binding: AppLanguage={Binding Path=ApplicationLanguage, Source={x:Static Application.Current}} This works
Current Situation: Direct Binding I have an NSTableView which displays the data that comes
Let's say I have 2 tables: Users user_id name Tags tagger_id tagged_id This describes
If I have a table called enrollments and this is my current basic enrollment
I have a table row setup using relative layout. It has 2 TextView both
What is current directory of shell script? Is this current directory from which I

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.