Skip to main content
Inspiring
November 23, 2007
Question

search interface

  • November 23, 2007
  • 2 replies
  • 395 views
well i am currently working on a search system of my databsae where i am bit confusd, i have ones ingle field for search.

the serach it makes with the table properties which carry the values of city, subdision and type of property as forien keys to the properties table. these three are all numeric as they carry the promary key value of their own.

so i amended up something like this:

but it does not seems to be working..i am using mysql

here is te code what i try to fing out, i want that if any user enter cityname the search show him all the properties belonging to that search..

<cfquery name="Recordset1" datasource="#request.dsn#">
SELECT properties_details.*, cityname as dCity,
property_type_name as ptype, Subdivion_name as sub_name
FROM properties_details
JOIN cities ON
cities.cities_id = properties_details.city_id
JOIN properties_types ON
properties_types.ptype_id = properties_details.ptype_id
JOIN cities_subdivision ON
cities_subdivision.sub_id = properties_details.sub_id
WHERE 0=0
<CFIF URL.search_string is not "">
AND property_unique_name LIKE '%#URL.search_string#%'
</CFIF>
<CFIF URL.search_string is not "">
AND cityname LIKE '%#URL.search_string#%'
</CFIF>
<CFIF URL.search_string is not "null">
AND Subdivion_name LIKE '%#URL.search_string#%'
</CFIF>
<CFIF URL.search_string is not "">
AND property_type_name LIKE '%#URL.search_string#%'
</CFIF>
</cfquery>


This topic has been closed for replies.

2 replies

Inspiring
November 24, 2007
If you use just ORs, you will get every row because of the 0=0. Changing that to 0=2 will get you on the right track.
Inspiring
November 24, 2007
if i omit the 0=0 or 0=2 then it will fetch the same results., beacuse i will having more fields to get search on from the table properties
Inspiring
November 23, 2007
You are doing an awful lot of things based on the url search string. If I give you a string of "abc", your search will return only those records where the property_unique_name, property_type_name, cityname, AND subdivision_name have those letters.

That's probably not your intent.
Inspiring
November 24, 2007
well i tried it with OR but i wanna know is my sql statement is right , but OR is also is not working

well i think i try like serarching property from properties_details table which contains all the three ID's of the cityname, subdivion, property type tables.

because i am bit confused at this thing..

plz guide me thanks