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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:57:09+00:00 2026-05-15T11:57:09+00:00

I’m trying to extract data from a many to many table configuration. I’m sorry

  • 0

I’m trying to extract data from a many to many table configuration.
I’m sorry if this explanation is vague, but it’s the best I can do without a lengthy explanation of the whole inner workings of my program.

I have 2 modules in an application.
Module one shows information relevant to a group of items.
And it strips out information that is not present in all items. (lowest common denominator)

So…
Item one is red and green.
Item two is green and blue.
And item three is just green.

So table one would be the list of items and table two would be the list of colors.
And of course, a third table holds the relationships.

I’m trying to get the module to only show elements from table two that are present in all items from table one.

In this case, it would strip the shown elements to just green because that’s the only common element.

I tried doing this programatically and it was a nightmare to look at and debug. That and this will be a mobile app so all the for loops will really lag my program. I know that there has to be a way to do it with SQL, but after several hours researching, I still can’t seem to wrap my head around how.

Thanks.

UPDATE for clarity:

OK, I made 2 mistakes in my question.
First off, I’m not looking for common quantity, I’m looking for common VALUE.
So I only want colors that exist in all three items and to discard the rest.
Second I should have been more specific. I’m developing an app for the Android phones, so I’m using Java and SQLite.

Here’s what I have so far in the original form, not the color example I used.
In this code tag would equal color and other would equal item…


SELECT DISTINCT tag.name
FROM other_tag_relationship AS otr
JOIN tag ON otr.tag_id = tag._id
WHERE otr.other_id in (2, 3, 4);

This obviously returns a distinct list of all tags for all of the given others.

What I want to do now is show only the tags that are available in ALL others and discard the rest. Like remove any tags from 2 that aren’t also in 3 and 4 for example. Also, the list (2, 3, 4) would be generated dynamically at run time.

Thanks again.

  • 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-05-15T11:57:10+00:00Added an answer on May 15, 2026 at 11:57 am

    From your description, it sounds like you want a list of Colors (Table 2) that are associated with all items (Table 1) via the middle table 3 (ItemColors):

    Select IC.ColorId, C.Name
    From ItemColors As IC
        Join Colors As C
            On C.Id = IC.ColorId
    Group By IC.ColorId, C.Name
    Having Count(*) =   (
                        Select Count(*) 
                        From Items As I2 
                        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.