Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I've this SQL query :

SQL
SELECT * FROM Homes Where (`Sub-Type`='Any Type') AND (`tarea` BETWEEN '1' AND '50') AND (`Price` BETWEEN '1' AND '10000') AND (`Bedrooms` BETWEEN '1' AND '10') AND (`Bathrooms` BETWEEN '1' AND '10')


What do I do to make it so that it would return results with ANY values in some fields, some thing like wildcard. For example I want to change the values of 'Bedrooms' from any to any. What do I do?
Posted
Comments
[no name] 1-Aug-12 10:03am    
You can remove "AND (`Bedrooms` BETWEEN '1' AND '10')" from where clause.
ZurdoDev 1-Aug-12 10:49am    
It might be easier to default your parameters if they are not passed in. So, if Bedrooms is not specified default the parameter to 1, for example.

1 solution

If you want any bedrooms then remove the filter for bedrooms.
SQL
SELECT * FROM Homes Where (`Sub-Type`='Any Type') AND (`tarea` BETWEEN '1' AND '50') AND (`Price` BETWEEN '1' AND '10000') 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900