Help me make this more efficient. To many or's in the select statement.
I have two search fields basically city and state. Ultimately if someone fills out both I would like to retrieve only those selected cities in that state. Right now it gets all cities in the state. But, if I take out the state part then I get an error that the form field was not specified. Any help appreciated. I can check for state on the next page, but isn't that more inefficientcy?
DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
I have two search fields basically city and state. Ultimately if someone fills out both I would like to retrieve only those selected cities in that state. Right now it gets all cities in the state. But, if I take out the state part then I get an error that the form field was not specified. Any help appreciated. I can check for state on the next page, but isn't that more inefficientcy?
Code:
SELECT general.city,general.state,general.name,States.image,States.state_name,States.state_pic
FROM general INNER JOIN States
ON general.state=States.state_pic
WHERE state='#form.state#' and city LIKE '%#form.search#%' or state='#form.state#' or city LIKE '%#form.search#%' or zip='#form.search#' or name LIKE '%#form.search#%'
GROUP BY general.city, general.state,States.image,States.state_name,States.state_pic,general.name
ORDER BY general.city,States.image,States.state_name,States.state_pic
</cfquery>
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic