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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:43:14+00:00 2026-05-10T17:43:14+00:00

In the following one to many CREATE TABLE source(id int, name varchar(10), PRIMARY KEY(id));

  • 0

In the following one to many

CREATE TABLE source(id int, name varchar(10), PRIMARY KEY(id)); CREATE TABLE params(id int, source int, value int); 

where params.source is a foreign key to source.id

INSERT INTO source values(1, 'yes'); INSERT INTO source values(2, 'no');  INSERT INTO params VALUES(1,1,1); INSERT INTO params VALUES(2,1,2); INSERT INTO params VALUES(3,1,3);  INSERT INTO params VALUES(4,2,1); INSERT INTO params VALUES(5,2,3); INSERT INTO params VALUES(6,2,4); 

If i have a list of param values (say [1,2,3]), how do I find all the sources that have ALL of the values in the list (source 1, ‘yes’) in SQL?

Thanks

  • 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. 2026-05-10T17:43:14+00:00Added an answer on May 10, 2026 at 5:43 pm

    Edit Modified to handle case where there can be multiple occurances of the value for a given source.

    Try this:

    SELECT     * FROM     source WHERE     (         SELECT COUNT(DISTINCT value)         FROM params         WHERE params.source = source.id           AND params.value IN (1, 2, 3)     ) = 3 

    You can rewrite it to a GROUP BY as well:

    SELECT     source.* FROM     source     INNER JOIN params ON params.source = source.id WHERE     params.value IN (1, 2, 3) GROUP BY     source.id,     source.name HAVING     COUNT(DISTINCT params.value) = 3 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Observe the following table model: CREATE TABLE [site].[Permissions] ( [ID] INT REFERENCES [site].[Accounts]( [ID]
I want a query to create a one row table with as many columns
I have the following database structure: Table 1 Table 2 Table 3 tid_1 ----(many-to-one)----
How would one programatically reproduce the following effect? (source: artext.co.uk ) I'd like to
there are three existing tables defined like the following: create table business_units (id number(10,0)
We have similar code to the following in one of our projects. Can anyone
I have the following snippet in one of my html pages : <div class=inputboximage>
Say I have the following code: function One() {} One.prototype.x = undefined; function Two()
As you know, in ASP.NET, you can store session data in one of following
Which one of the following do you do: var = true; if (...) var

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.