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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:25:56+00:00 2026-06-05T08:25:56+00:00

Suppose I have two tables: product ——- productid name and language ——– productid code

  • 0

Suppose I have two tables:

product
-------
productid
name

and

language
--------
productid
code

I have three products:

1, 'homebody' -> 1, EN
2, 'continetnal' -> 2, FR
                 -> 2, EN
                 -> 2, ES
3, 'westy'       -> 3, EN
                 -> 3, ES
                 -> 3, FR
                 -> 3, PT
4, 'oktoberfest' -> 4, DE

Suppose I have a list of languages I am interested EN, FR, ES in I would like to create three types of query to select a number of products.

  1. Match any language in my list (‘homebody’, ‘continental’, ‘westy’)
  2. Match all languages in my list (‘continental’, ‘westy’)
  3. Match exactly languages in my list (‘continental’)

I think the solution to the first is just:

SELECT * FROM products AS p JOIN language AS l ON (p.productid = l.productid) WHERE l.code IN ('EN', 'ES', 'FR')

What is a good way for me to solve the other queries? I suspect something where I count the number of languages associated with my product and make sure it is equal-to or at-least the number of languages in my query, but not sure how to make this happen.

  • 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-05T08:25:57+00:00Added an answer on June 5, 2026 at 8:25 am

    if you can’t have two times FR (or any language) for the same product :

    2.

    SELECT p.productid, p.name 
    FROM products AS p 
    JOIN language AS l ON (p.productid = l.productid) 
    WHERE l.code IN ('EN', 'ES', 'FR')
    GROUP BY p.productid, p.name
    HAVING COUNT(*) = 3
    

    3.

    WHERE l.code IN ('EN', 'ES', 'FR')
    AND NOT EXISTS (SELECT NULL FROM language where productid = p.productid
       AND code NOT IN ('EN', 'ES', 'FR')
    GROUP BY p.productid, p.name
    HAVING COUNT(*) = 3
    

    or if you wanna retrieve languages codes

    SELECT * FROM products p
    JOIN language l on p.productid = l.productid
    where p.productid IN
      (SELECT p1.productid from product p1
       JOIN language AS l1 ON (p1.productid = l1.productid) 
        WHERE l1.code IN ('EN', 'ES', 'FR')
        GROUP BY p1.productid,
        HAVING COUNT(*) >= 3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL server 2008: Suppose I have two tables. Table1 has 3 fields: Name,
Suppose I have these two tables : TABLEA TABLEB ----------- ----------- ID | NAME
Suppose you have two tables: Musicians musicianID (primary key, int) name (varchar) instrument (varchar)
Suppose I have two tables that are linked (one has a foreign key to
Suppose I have two tables on a database, T 10 and T 11 ,
Suppose we have the contents of tables x and y in two dataframes in
Suppose you have two tables in PostgreSQL. Table A has field x , which
Suppose I have two tables, table A and table B, and that table A
Suppose I have two tables: Group ( id integer primary key, someData1 text, someData2
Suppose I have two tables, Customer and Vendor. I want to have a common

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.