Hi,

I only thought of regexp because you do not need any wild cards with  
it. using REGEXP 'Ke' would find Key, or Backer. I am examining the  
posted fields here is a snippet of code:

$query = 'SELECT * FROM `memberDirectory` WHERE';

if (isset($_POST['business_name'])){
     if ( $_POST['business_name'] != ""){
         $_POST['business_name'] = htmlspecialchars(trim($_POST 
['business_name']));
             $query .= ' `business_name` LIKE "%'.$_POST 
['business_name'].'%"';
         if ( isset($_POST['address']) || isset($_POST['suite']) ||  
isset($_POST['city']) || isset($_POST['category']) ) {
                 $query .= ' OR';
         }
     }
}

$query .= ' ORDER BY `business_name`';

I'm testing east field for it's presence and content and building the  
query string as the script moves along. So I think this should work  
fine. The table currently has 200 records and should not exceed 300  
anytime soon. It seems pretty responsive.

Mike
-- 
Mike Brandonisio          *    Web Hosting
Tech One Illustration     *    Database Applications
tel (630) 759-9283        *    e-Commerce
[EMAIL PROTECTED]    *    http://www.jikometrix.net

     JIKOmetrix - Reliable web hosting

On Jun 27, 2005, at 5:37 PM, Pete wrote:

> 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
>
>
>
>
>
>
>
>
>
>
>



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