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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:21:53+00:00 2026-05-22T22:21:53+00:00

I’m trying to build a filtering system for products. Products have many attributes including

  • 0

I’m trying to build a filtering system for products. Products have many attributes including price, size(cm) and (# of) sides. I want to construct an SQL query that always returns ALL the products but orders them on how closely they meet the search criteria.

For example lets say I have the following products:

Product A
Price: 250
Size: 50
Sides: 4

Product B
Price: 300
Size: 60
Sides: 3

Product C
Price: 200
Size: 60
Sides: 5

And have a search criteria of:

Price: $210 – $260

I want it to return:
Product A, Product C, Product B

A is first because it meets all the search criteria. C is ahead of B because $200 is closest to the $210-$260 range than $300.

That’s a fairly simple case but the search could involve any attribute(s).

The algorithm I have in my head is doing some sort of standard deviation calculation for each attribute which would give you a ‘score’ of how closely that attribute meets the search criteria, these scores could be summed up across a product to give a total score of how relavant the product is. Is that along the right track?

I realize this is a fairly complicated question, I’m really just looking for some guidance more than anything.

  • 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-22T22:21:54+00:00Added an answer on May 22, 2026 at 10:21 pm

    You basically have to come up with a ‘distance’ function for each row which returns 0 if all criteria match or some positive value indicating how close otherwise. Each of the different columns will have to have some weight as being off by $1 is not as far off as being off by 1 number of sides. For the price if it’s below 210 the unweighted distance would be (210 – price), if the price is over 260 the unweighted distance for the price column would be (price – 260). Then you can add up the weighted distances w1 * price_distance + w2 * size_distance + s3 * sides_distance. Then you can do a order by distance.

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.