In message <[EMAIL PROTECTED]>, Mike
Brandonisio <[EMAIL PROTECTED]> writes
>Hi Pete,
>
>On Jun 27, 2005, at 2:41 PM, Pete wrote:
>
>>
>> Then it won't be as slow - but try to lose the LIKE.
>>
>>
>
>Thank you for dissecting that query. I'm creating a search page for a  
>chamber of commerce, so users can search for members. I understand  
>that using '="fred"' would be faster than 'LIKE '%fred%', but users  
>may be doing searches for partial city names or part of company name.  
>Is this a bad usage of LIKE? Would '="%fred%"' or '="%b%"' find the  
>same thing as using LIKE? If you had to do a partial search and could  
>not train users to use wild cards or give them options of =, != or  
>LIKE. It has to be a catch all search. Would using 'REGEXP' be better?

I can't see how REGEXP would help in this case.  But ... if you *have*
to use LIKE, then you have to - but why not examine each field, and drop
the empty ones?  If the user added nothing in the City field, then don't
put it in the SQL Query.  As most people will only enter one or two
fields to start with, you are halving the search time already.

-- 
Pete Clark

http://www.hotcosta.com
http://www.spanishholidaybookings.com




The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to