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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:38:34+00:00 2026-06-11T14:38:34+00:00

I m having trouble writing a query, I have two tables. Property Table (property)

  • 0

I m having trouble writing a query, I have two tables.

  1. Property Table (property)

    • id
    • property_name
    • property_type
    • price

there are two types of property, commercial or residential. If type is residential the price is for whole property. But if the type is commercial, each flat have different prices, like Ground Floor, 1st floor, 2nd floor, 3rd floor. and so on. So i made a second table

  1. Property Price Table (price_for_commerical_prop)
    which has following fields

    • id
    • property_id
    • floor_id
    • price

this table may contain multiple row for one property, depending upon the number of flats the property has. floor_id contains value 0 for ground floor, 1 for 1st floor and so on.

My problem is that. I have a search field to search property based on price. So If user enters price, i have to search price in price field of 1st table as well as 2nd table. And return the rows based on the search criteria. Can anybody shed light on how to do this?

  • 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-11T14:38:36+00:00Added an answer on June 11, 2026 at 2:38 pm

    To search for a price range of 10 to 20, you could:

    select  *
    from    Property p
    left join
            price_for_commerical_prop pfcp
    on      p.id = pfcp.property_id
    where   case 
            when p.property_type = 'residential' then p.price
            when p.property_type = 'commercial' then pfcp.price
            end between 10 and 20
    

    The case returns the price from Property for residential, and the price from price_for_commerical_prop for commercial.

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

Sidebar

Related Questions

I am having trouble writing a query. Lets say I have a table full
I'm having trouble writing this Query. I have 2 tables, vote_table and click_table. in
I am having trouble writing a query. I have been working with UNION on
I am having trouble writing a query on a mysql table of user activity
i am having trouble with cakephp and writing an sql query, I have the
I'm having some trouble writing a query. For example: Let's say I have just
I'm having trouble writing a query. I have a support tabled called 'MYTABLE' and
I am having trouble writing query so that I can query the content of
I'm new to linq and having trouble writing two simple queries. For some reason,
I'm quite new to sql and I'm having trouble writing this i have a

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.