In message <[EMAIL PROTECTED]>, Mike
Brandonisio <[EMAIL PROTECTED]> writes
>>> $query = 'SELECT *
>>>         FROM `memberDirectory`
>>>         WHERE `business_name` LIKE ''%'.$_POST 
>>> ['business_name'].'%'' OR
>>>         `address` LIKE ''%'.$_POST['address'].'%'' OR
>>>         `suite` LIKE ''%'.$_POST['suite'].'%'' OR
>>>         `city` LIKE ''%'.$_POST['city'].'%'' OR
>>>         `cat1` LIKE ''%'.$_POST['category'].'%'' OR
>>>         `cat2` LIKE ''%'.$_POST['category'].'%'' OR
>>>         `cat3` LIKE ''%'.$_POST['category'].'%''
>>>         ORDER BY `business_name`';
>>>
>> And I hope that your visitors have plenty of time to wait, because  
>> that
>> query looks as though it will take ages to run.

>I'll do that. Did I make typical newbie error in formulating my  
>query? If so where ... why would it take ages to run?

I just realised that you have 
>''%'.$_POST['city'].'%''
>

Your quotes confuse the query!

'SELECT *
   FROM `memberDirectory`
        WHERE `business_name` LIKE "%'.$_POST['business_name'].'%"' OR

Note the double quote before the first %, or after the second one.
You could have put 
        WHERE `business_name` LIKE \'%'.$_POST['business_name'].'%\'' OR

So what was " before, is now \'

!!!! Must look more carefully next time.



But it will be slow, because the database cannot use any indexes with
LIKE "%fred%"
If it would work in your system, then
="fred"
could use indexes, and would run faster.

> There are only  
>5 search field on the form page that POST's to this result page.

You will have to scan the entire database 5 times, (because you are
using LIKE "%   - and if it doesn't find anything, I suspect that the
search would take even longer.

> This  
>is a test query the query that runs will be conditional based on each  
>field that submits data. It will  not be a catch all query like  
>posted here.

Then it won't be as slow - but try to lose the LIKE.

>Mike

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