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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:39:14+00:00 2026-05-19T13:39:14+00:00

i have gotten our system to return information correctly, however i now have the

  • 0

i have gotten our system to return information correctly, however i now have the problem of returning information when we are applying filters. the query in question is:

SELECT `products`.* 
CONCAT( '[', GROUP_CONCAT( DISTINCT '{', '"id":"', `product_variations`.`id`, '"', ',', '"id_product":"', `product_variations`.`id_product`, '"', ',', '"sku":"', `product_variations`.`sku`, '"', ',', '"options":"', `product_variations`.`options`, '"', ',', '"quantity":"', `product_variations`.`quantity`, '"', ',', '"price":"', `product_variations`.`price`, '"', '}' SEPARATOR ',' ), ']' ) as `_variations`, 
CONCAT( '[', GROUP_CONCAT( DISTINCT '{', '"id":"', `product_images`.`id`, '"', ',', '"id_product":"', `product_images`.`id_product`, '"', ',', '"location":"', `product_images`.`location`, '"', ',', '"order":"', `product_images`.`order`, '"', ',', '"variation_key":"', `product_images`.`variation_key`, '"', ',', '"variation_values":"', `product_images`.`variation_values`, '"', '}' SEPARATOR ',' ), ']' ) as `_images`, 
CONCAT( '[', GROUP_CONCAT( DISTINCT '{', '"id":"', `product_attributes`.`id`, '"', ',', '"id_product":"', `product_attributes`.`id_product`, '"', ',', '"key":"', `product_attributes`.`key`, '"', ',', '"value":"', `product_attributes`.`value`, '"', '}' SEPARATOR ',' ), ']' ) as `_attributes`
FROM (`products`)
LEFT JOIN product_variations ON products.id = product_variations.id_product
LEFT JOIN product_images ON products.id = product_images.id_product
LEFT JOIN product_attributes ON products.id = product_attributes.id_product
WHERE ( `products`.`id_category` = "11" OR `products`.`id_category` = "12" OR `products`.`id_category` = "9" )
AND ( product_attributes.key = "color" AND product_attributes.value IN ( "Red","Orange" ) ) 
AND ( product_attributes.key = "size" AND product_attributes.value IN ( "L","M" ) )
GROUP BY `products`.`id`
LIMIT 10

Ignoring the CONCAT things ( which return the attributes etc as json data ) what i am trying to get to work is, for example, if a product has the following attributes:

color=Red
color=Orange
color=Blue
size=L
size=M
size=S

so if i want to display products where

color=Red OR color=Orange
AND
size=L OR size=M

this product would be returned,
the problem obviusly lies in the fact

AND ( product_attributes.key = "color" 
AND ( product_attributes.key = "size" 

cannot be true, but i want it to be ANY of the children, if it is only 1 filter, it works fine, but multiple “different” filters and it breaks,

also, it will only return the attributes in question which passed the filter.

i would like it to return ALL attributes for a product which has passed the filter, the more i look into this the more i think its not possible. Does anybody know of a way of doing this?

  • 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-19T13:39:15+00:00Added an answer on May 19, 2026 at 1:39 pm

    You would need to write the logic in a HAVING clause, example:

    HAVING COUNT(IF(product_attributes.key = "color" AND product_attributes.value IN ("Red","Orange"),
        1, NULL)) > 0
      AND COUNT(IF( product_attributes.key = "size" AND product_attributes.value IN ( "L","M" ),
        1, NULL)) > 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have gotten a great deal of help from KandadaBoggu on my last question
We have gotten several emails and phone calls about yellow text appearing on our
I have gotten everything working for my class in which I am using Tomcat
I have a client who's wordpress sites have gotten hacked twice by iframe scammers.
I have been searching everywhere for the following functionality in Lisp, and have gotten
I have been learning Hibernate for the past few weeks, I have gotten most
I am working on Conway's Game of Life currently and have gotten stuck. My
I'm brand spanking new at Spring and have gotten a majority of the knowledge
I am working on an image generation script in PHP and have gotten it
I'm working on learning Objective-C/Coaoa, but I've seem to have gotten a bit stuck

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.