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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:07:16+00:00 2026-06-12T19:07:16+00:00

I will try to explain my problem as much as I can. I have

  • 0

I will try to explain my problem as much as I can.

I have a search form where user can select different parameters and enter different values to perform a search for the properties. Like I have a table tbl_properties.

In search form user selects, property_category, property_type [a lease, sale or rent], inputs price range, no_of_bedrooms, location,districts, property_area, etc. The property attributes may be in tbl_properties or in other lookup tables. Writing query is not my problem, but the problem I m in is, I want to sort records in following pattern in search results

  1. First show result – price that matched the location in descending order
  2. Then show – price that matched the district
  3. Then show – No of bedrooms match in same district
  4. Then show – Price/bedrooms/property area matched but in different district

I just want a hint how can the records be sorted in these orders?

EDIT

Here is the brief description of the table structure I have

tbl_properties
-------------------

property_id   INT
category_id    INT
property_name VARCHAR
price         INT
district_id   INT
location       VARCHAR
property_type  ENUM('lease','sale','rent')


tbl_category
-------------
category_id   INT
category_name VARCHAR


tbl_districts
-----------------
district_id INT
district_name VARCHAR


tbl_property_details
------------------------
detail_id      INT
property_id     INT
no_of_bedrooms  INT
property_area  DECIMAL

Thanks

  • 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-12T19:07:17+00:00Added an answer on June 12, 2026 at 7:07 pm
    order by case
        when price between @priceMin and @priceMax 
            and location = @location then 1
        when price between @priceMin and @priceMax 
            and district_id = @districtid then 2
        when no_of_bedrooms = @no_of_bedrooms 
            and districtid = @districtid then 3
        when price between @priceMin and @priceMax 
            and no_of_bedrooms = @no_of_bedrooms 
            and property_area = @property_area and districtid <> @districtid then 4
        else 5
    end, price desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will try to explain things as much as I can. I have following
I will try to explain my problem as clear as I can. I have
I have a problem and I will try to explain the issue: I have
I will try to explain my problem clearly: I have two tables: document and
I will try to explain my problem. I have 4 files index.html, event.js, start.js
I will try to explain the problem that I have with this code. This
Good day, i will try to explain my problem as best as i can.
I will try to explain the problem I'm facing. I have two tables: Team
I have CSS problems. I will try to explain my problem to you with
i will try to explain the problem very clear. I user MicroSoftReportViewer where 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.