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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:04:32+00:00 2026-05-24T22:04:32+00:00

could anyone help me build up a query based on the query bellow. As

  • 0

could anyone help me build up a query based on the query bellow.

As you can see I have a product with specifications and certain groups which are build up in the front-end. I know the problem, 1 column can’t be 2 values at once but I need only those products that are in those 2 groups.

To illustrate, product_specification_sid, id 2 3 and 4 are sizes and de rest 8 ~ 11 are colors, so I would like to select a product that has 2 and 3.

Inner joining the table double isn’t an option since the groups (sizes, colors) may vary in the future.

SELECT
    products.*,
    categories.*,
    manufacturers.* 
FROM products
INNER JOIN  product_categories ON product_category_pid = product_id
INNER JOIN  categories ON product_category_cid = category_id
INNER JOIN  manufacturers ON product_manufacturer = manufacturer_id
INNER JOIN  product_specifications ON product_specification_pid=product_id
WHERE 
    product_active = 1  
AND 
(
    product_specification_sid in (3)  
AND  
    product_specification_sid in (8,9,6,7,10,11)  
) 
GROUP BY product_id
  • 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-24T22:04:34+00:00Added an answer on May 24, 2026 at 10:04 pm

    You can use a having clause instead.

    SELECT
        products.*,
    FROM products
    INNER JOIN  product_categories ON product_category_pid = product_id
    INNER JOIN  categories ON product_category_cid = category_id
    INNER JOIN  manufacturers ON product_manufacturer = manufacturer_id
    INNER JOIN  product_specifications ON product_specification_pid=product_id
    WHERE product_active = 1  
    GROUP BY product_id
    HAVING COUNT(CASE WHEN product_specification_sid in (3) THEN 1 END) > 0
     AND COUNT(CASE WHEN product_specification_sid in (8,9,6,7,10,11) THEN 1 END) > 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if anyone could please help me I have been using HTML tidy
Can anyone help me with this? I have not been able to find anything
I wonder if anyone can help with the following. I have integrated both iAds
could anyone help me with this problem. What I have done is I wrote
I need to get substed drive letter in Perl. Could anyone kindly help me?
OK, if anyone could help me with this I'd be much appreciative. If you
I am getting the following error and could use some help resolving it. Anyone
Could anyone can tell me where I can find full ASP.NET MVC beta documentation?
I have an embarrassing question regarding Access. I can build relational databases in my
Could anyone please describe how to use NHibernate Query Analyzer? I downloaded it and

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.