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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:08:48+00:00 2026-05-18T20:08:48+00:00

I have two tables containing product information, and product variations. I’m trying to list

  • 0

I have two tables containing product information, and product variations. I’m trying to list all products, and it’s colours variations.

The table products contains general information’s about the product (name, description, enabled etc.)

The table product_attributes contains the different options of the product (color, size, price etc.)

I’m trying to get all available products, and if the product is available in two colors, it should show as two listings. Unfortunately my query below list far more options, since there will be a row for each size combination as well.

SELECT pa.price, pa.color, p.id, p.url_key, p.name FROM product_attributes AS pa INNER JOIN products AS p ON pa.product_id = p.id && p.active = 1

Does anyone have an idea how to achieve this, the best and smartest way?

I hope you understand my question

Thanks in advance,

Regards!

id  mediumint(7)    NO  PRI NULL    auto_increment
type    tinyint(3)  NO      1    
url_key varchar(54) NO      NULL     
name    varchar(48) NO      NULL     
description text    NO      NULL     
weight  float   NO      0    
active  tinyint(3)  NO      0    
in_feed tinyint(3)  NO      0    
tax_class   tinyint(3)  NO      0    
meta_title  varchar(48) NO      NULL     
meta_keywords   varchar(48) NO      NULL     
meta_description    text    NO      NULL     
manage_stock    tinyint(3)  NO      0    
attribute_designers_id  mediumint(7)    NO      0    
attribute_size_family_id    mediumint(7)    NO      0

id  mediumint(7)    NO  PRI NULL    auto_increment
product_id  mediumint(7)    NO  MUL NULL     
sku varchar(48) NO      NULL     
price   float   NO      NULL     
special_price   float   NO      0    
special_price_from_date datetime    NO      NULL     
special_price_to_date   datetime    NO      NULL     
cost    float   NO      0    
new_from_date   datetime    NO      NULL     
new_to_date datetime    NO      NULL     
attribute_colors_id mediumint(7)    NO      NULL     
color   varchar(24) NO      NULL     
attribute_sizes_id  mediumint(7)    NO      NULL     
quantity    mediumint(7)    NO      0
  • 1 1 Answer
  • 1 View
  • 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-18T20:08:49+00:00Added an answer on May 18, 2026 at 8:08 pm

    You need to add a group by:

    SELECT pa.price, pa.color, p.id, p.url_key, p.name
    FROM product_attributes AS pa
    INNER JOIN products AS p
    ON pa.product_id = p.id && p.active = 1
    GROUP BY p.id, pa.color
    

    Note that your column pa.price probably makes no sense here as the price almost certainly depends on the size, but you don’t know which size the price is for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables containing product information, and product variations. I’m trying to list
I have two tables. Table A contains a list of departments, there are 20
I have two tables. Table A: Contains a list of songs, song artwork, mp3
I have two MySQL database tables: one containing a list of championships and another
I have two tables, one containing a list of different options users can select
hope this makes sense. I have merged together two tables one containing information about
I have two tables, one is a list of tasks. The other containing historical
I have two tables, one table has some information in each row along with
I have two mysql tables: Item containing items that one can buy: CREATE TABLE
I have a table containing information on customers and products in an Access database:

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.