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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:21:01+00:00 2026-05-14T07:21:01+00:00

Hello i have a products table that contains normal products and configurable product It

  • 0

Hello i have a products table that contains normal products and configurable product

It has a basic stucture of:

  • id
  • name
  • price
  • configurable (‘yes’, ‘no’)
  • id_configuration

Normal products have configurable no and 0 as id configuration, and configurable products have it set to yes and have the same id_configuration value.

The current query is:

SELECT `products`.* 
FROM `products`, `categories`, `product_categories` 
WHERE `categories`.`id` = 23 AND 
      `products`.`id` = `product_categories`.`id_product` AND 
      `categories`.`id` = `product_categories`.`id_category` AND 
      `products`.`active` = 'yes' 
ORDER BY `pos_new` ASC, `created` DESC LIMIT 0,20

I was wondering if there is a way to group by id_configuration, but only for the configurable products. The reason is that i want only one of the configuration products to show in search.
I was thinking i could do a join, but was wondering if there is a way to do some kind of special group by.
For example for configurable yes the field should be id_configuration otherwise it should be the id field

Thanks a lot for any sugestions

  • 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-14T07:21:01+00:00Added an answer on May 14, 2026 at 7:21 am

    You can use a CASE statement in the GROUP BY clause, and group by id_configuration if configurable is ‘yes’, or by id, which is unique (and therefore the equivalent of not grouping) if not.

    SELECT * FROM `products` 
    GROUP BY CASE `configurable` WHEN 'yes' THEN `id_configuration` ELSE `id` END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a table in some cms (products) that has 3 columns: product_id
Hello i am in a delima Suppose that i have 50 products in a
hello i have a big table of products in each tree there is a
Hello I have a products table having fields products_id,products_number,products_status,products_price where products_id is auto_increment and
Hello StackOverflow community, I have 2 tables products ======= id name prices ====== id
I have following tables: products - 4500 records Fields: id, sku, name, alias, price,
hello I have my code that connects to my ftp server $conn_id = ftp_connect($ftp_server);
Hello I have a datatable that I would like to filter with a single
Hello I have a table with articles and the articles have a column category.
I have grid <?php $this->widget('bootstrap.widgets.TbGridView',array( 'id'=>'products-grid', 'htmlOptions'=>array('class'=>'grid-view table-striped',), 'dataProvider'=>$model->search(), 'columns'=>$columns, )); ?> $model->search() return

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.