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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:08:20+00:00 2026-05-11T00:08:20+00:00

I have the following five tables: ISP Product Connection AddOn AddOn/Product (pivot table for

  • 0

I have the following five tables:

  • ISP
  • Product
  • Connection
  • AddOn
  • AddOn/Product (pivot table for many-to-many relationship).

Each Product is linked to an ISP, each Connection is listed to a Product. Each product can have a number of add-ons, through the use of the pivot table (which simply has 2 fields, one for the product ID and one for the AddOn ID).

The result I am interested in is each connection with the addons listed (I am making use of MySQL’s GROUP_CONCAT for this, to make a comma-separated list of the addon’s name field). This works fine as is, the query looks something like this:

SELECT i.name AS ispname, i.img_link, c.download, c.upload, c.monthly_price, c.link,  GROUP_CONCAT(a.name) AS addons, SUM(pa.monthly_fee) AS addon_price FROM isp i JOIN product p ON i.id = p.isp_id JOIN `connection` c ON p.id = c.product_id LEFT JOIN product_addon pa ON pa.product_id = p.id AND pa.forced = 0 LEFT JOIN addon a ON pa.addon_id = a.id GROUP BY c.id 

I am using LEFT JOINS as it is possible for products to have no addons at all.

My problem is that it is possible to select some addons that listed connections MUST have, presented as a list of addon IDs, like (1,14,237). If I put it in as an additional condition in the JOIN statements (AND pa.addon_id IN (…)), it will return all connections that have just one of the listed addons, but not necessarily all of them.

Is there some way to return all connections that as a minimum have all the addons (they can have additional as well) via SQL?

  • 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-11T00:08:21+00:00Added an answer on May 11, 2026 at 12:08 am
    GROUP BY set-of-column HAVING SUM(CASE WHEN ISNULL(pa.addon_id, 0) IN (1,14,237) THEN 1 ELSE 0 END) = 3 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 75k
  • Answers 75k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Almost certainly the problem is environmental - not source related.… May 11, 2026 at 2:52 pm
  • added an answer Call a function instead. <select id='value' onchange='sendForm()'> ...script block... function… May 11, 2026 at 2:52 pm
  • added an answer O(n log n) doesn't mean that the number of comparisons… May 11, 2026 at 2:52 pm

Related Questions

I have a report that I created with Crystal Reports 2008. This report uses
I have a social networking site where users update their moods, profiles and add
Each product in my database can have at least three and sometimes four or
I have the following html <div id=menu> <ul class=horizMenu> <li id=active><a href=# id=current>About</a></li> <li><a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.