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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:04:11+00:00 2026-05-27T13:04:11+00:00

Tables product : id, price productattribute :id, productid, attributeid attributes : id, value, attributetypeid

  • 0

Tables

product: id, price
productattribute:id, productid, attributeid
attributes: id, value, attributetypeid
attributetype:id, name

Query

select p.Name, p.Price, att.Id, att.Value, at.Id, at.Name
from Product p
inner join ProductAttribute pa on pa.ProductId = p.Id
inner join Attributes att on att.Id = pa.AttributeId
inner join AttributeType at on att.AttributeTypeId = at.Id

Result

Name              Price    Id    Value     Id      Name
Slr camera           90     1    White      1      Color   
digital camera       98     2    Black      1      Color    
Slr camera           90     4    big        2      Size
digital camera       98     5    medium     2      Size

Now I want to retrieve products by filtering attributesid ie attributesid=1(which is white) and doing so must filter only the color attributetype not the size. What I mean is it should retrieve three rows now: rows with Color – White, Size – big and Size – medium.

  • 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-27T13:04:11+00:00Added an answer on May 27, 2026 at 1:04 pm

    Use a where clause to allow non-color attributes and color attributes if they’re white:

    where  at.AttributeTypeId <> 1 -- Non-color attribute
           or at.AttributeTypeId = 1 and att.Id = 1 -- White color
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query: SELECT product_description.name, product.quantity,product.price FROM product INNER JOIN product_description ON
I have 2 tables product and history product table: id name type price location
I have 2 tables, product has a primary key and a name, price has
I have two tables: product_description( name , product_id ) product( quantity, stock_status_id, price, product_id
I've got the database with 3 tables: product (id, name, price, ...) product_option (id,
I have two tables as follows PRODUCT table Id | Name | Price And
I have 2 tables. Table_1 has product 3 rows : ID, Quantity and Price.
I have two MySQL tables (product and price history) that I would like to
Now I have 4 tables: table categories: -id -category table products: -id -product -price
Let's say I have these tables/models: Product - id - last_updated_date - name -

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.