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

  • Home
  • SEARCH
  • 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 9095237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:32:51+00:00 2026-06-16T23:32:51+00:00

Hi i have question about a MySQL query. I have the following table: product_properties

  • 0

Hi i have question about a MySQL query.

I have the following table:

              product_properties             <-- table name
+------------------------------------------+    
|  id  |  property  |  value  | productid  | <-- field names
+------------------------------------------+
|   1  |  example   |    230  |         3  | +-- rows
|   2  |  power     |    110  |         3  | |
|   3  |  voltage   |    1.2  |         4  | |
|   4  |  example   |    240  |         4  | |
|   5  |  example   |    320  |         6  | |
|   6  |  power     |    100  |         4  | |
|   7  |  power     |    110  |         6  | +
+------------------------------------------+

I want to create a filter query. For example:

want to see all the products with ‘example’ that match with ‘230’. This will return one item, is i use:

SELECT * FROM product_properties WHERE property='example' AND value='230';

that was easy, but now i want to show all the products with ‘example’ that match with ‘230’ and ‘power’ that match with ‘110’.

i tried the following:

SELECT * FROM product_properties WHERE property='example' AND value='230' AND property='power' AND value='110';

SELECT * FROM product_properties WHERE property='example' AND value='230' OR property='power' AND value='110';

problem with the first query is, it will return empty, i get that.
problem with the second query is, that it is returning also the products with property ‘example 230,240,320’.

my question is what is the best way to use on this or shouldn’t i create a dynamic product properties table?

  • 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-06-16T23:32:52+00:00Added an answer on June 16, 2026 at 11:32 pm

    You have to filter on either or (since both cases can’t match for 1 record) and then find the properties where both match with a having clause

    SELECT product_id 
    FROM product_properties 
    WHERE property='example' AND value='230' 
    OR property='power' AND value='110'
    group by product_id
    having count(distinct property) = 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about MySQL InnoDB. For example: I have the following table
I have a question about my mysql query. I want to count the number
I have a question about converting charset from inside mysql query. I have a
I have a question about my mysql query syntax When i use this $result
I have a question about a MySQL query. I would (obviously) like to use
I have a short question about mysql query. What is correct? SELECT * FROM
I have a question about how GC works in Java. Consider the following code:
i have a question about basic mysql database optimisation. I have 3 tables, Articles,
Possible Duplicate: mysql count into PHP variable I have the following query that returns
Following my previous question . I have a table named activity with 2 columns:

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.