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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:08:12+00:00 2026-05-29T23:08:12+00:00

I am trying to get a product matching some custom parameters. So I have

  • 0

I am trying to get a product matching some custom parameters.
So I have to three tables – products, parameters and parametersitems.

Products table:

CREATE TABLE `products` (
  `ID` int(10) unsigned NOT NULL AUTO_INCREMENT
  `Title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `Content` longtext COLLATE utf8_unicode_ci NOT NULL,
  `Price` float(10,2) unsigned NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Parameter table:

CREATE TABLE `parameters` (
  `ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Label` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Parameter items table:

CREATE TABLE `parametersitems` (
  `ProductID` int(10) unsigned NOT NULL DEFAULT '0',
  `ParameterID` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`ProductID`,`ParameterID`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

So my question is how can I get only the products matching all the parameters.

The only way I could think of is joining the parameteritems table couple of times.
For example, here is a query to get the products matching two parameters:

SELECT 
    products.*
FROM 
    products 

INNER JOIN 
    parametersitems AS paritems1
    ON  
        paritems1.ItemID = products.ID 
        AND paritems1.ParameterID = 7

INNER JOIN 
    parametersitems AS paritems2
    ON  
        paritems2.ItemID = products.ID 
        AND paritems2.ParameterID = 11

My only concern is that the SELECT query will get slower and slower if there more parameters selected.
So is there a better way to handle this problem?

Thank you

  • 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-29T23:08:13+00:00Added an answer on May 29, 2026 at 11:08 pm
    select p.*
    from products p
    inner join (
        select ItemID
        from parametersitems 
        where ParameterID in (7, 11)
        group by ItemID
        having count(distinct ParameterID) = 2
    ) pm on p.ID = pm.ItemID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 equal-length lists and I am trying to get scalar product of
I have two entities: public class Product { [HiddenInput(DisplayValue=false)] public int ProductID { get;
I am trying to get a list of product id's that do not have
I am trying to build a Metro app that can get products off a
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
I'm trying to get a collection of selections but filtered on the parent product's
in C#, i'm trying to get some properties from the instances of Win32_Product, but
I am trying to get a list of Products that share the Category. NHibernate
On Magento, I'm trying to get avalable attributes per product in a new div
I'm trying to get a product's name and its number of sales from two

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.