Re: Search Query on two tables not working
| From: | Andrew Ballard | Date: | Tue, 21 Jul 2009 17:24:11 +0000 |
| Subject: | Re: Search Query on two tables not working | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-295633@lists.php.net to get a copy of this message | ||
On Tue, Jul 21, 2009 at 1:20 PM, Miller,
Terion<tmiller@springfi.gannett.com> wrote:
> Here it is...I see where it's doing the restaurant.name LIKE statement 2x which is prob
> messing it up right...but in the code why is it doing that twice..
>
> SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical FROM
> restaurants, inspections WHERE restaurants.name <> '' AND restaurant.ID =
> inspection.IDAND restaurants.name LIKE '%A%' AND restaurants.name LIKE '%A%'
> ORDER BY restaurants.name;
>
>
It's not the multiple LIKE statements. It is the concatenation, like I
said the last time. There is no white space between "inspection.ID"
and "AND".
You may indeed have problems with some of those repeated conditions on
restaurants.name, but if so they will be performance issues resulting
from table scans, and not the errors you are reporting.
Andrew