Lets say a user has a search form where he searches for properties. Lets say he selects:
Location : ABC Price Range : 1 million - 5 millions No. of Bedrooms Range : 5 - 12 State : XYZ County : PQR Category: MNO
There is a very slim chance of matching all the fields he selected to yield result from the database. so using AND in WHERE condition doesn’t seem effective here. what I want is –
- If all selection matched then no problem show the result
- If location, price range, state matched then show the result as well
- if location, no of bedrooms, category, state matched then show the result as well
- and so on….if any of the combination match then show the result
How about filtering the table for records that match on any search term and sorting the results in descending order of the number of matching terms: