You are here: Re: unusual behaiour with MySQL LIKE and LEFT join « PHP Programming Language « IT news, forums, messages
Re: unusual behaiour with MySQL LIKE and LEFT join

Posted by Rik on 08/21/07 14:37

On Tue, 21 Aug 2007 16:30:28 +0200, D_a_n_i_e_l <danwgrace@gmail.com> =

wrote:

> I have a form which has a field for filtering a query, the code behine=

> the form uses the LIKE clause. When I enter "a%" in the field the form=

> returns all records starting with "a" (as expected.) But when I enter=

> "e%" no rows are displayed even though there is one record on my
> database starting with "e". when. An SQL count with the same clauses
> returns 1 record (as expected.) I isloated the discrepancy to two SQL=

> calls:
>
> SELECT COUNT(*) FROM `testtbl` as a LEFT JOIN `testreftbl2` AS b ON
> a.`testref2`=3Db.`id`,`testreftbl1` AS c WHERE a.`testtext` LIKE "e%"
> AND a.`testdbl` LIKE "%" AND a.`testref1`=3Dc.`id`;
>
> no. of records=3D1
>
> SELECT
> a.`testid`,a.`testtext`,a.`testdbl`,a.`testopt`,a.`testradio`,b.`disp`=
,c.`disp`,a.`testchk`
> FROM `testtbl` as a LEFT JOIN `testreftbl2` AS b ON
> a.`testref2`=3Db.`id`,`testreftbl1` AS c WHERE a.`testtext` LIKE "e%"
> AND a.`testdbl` LIKE "%" AND a.`testref1`=3Dc.`id` ORDER BY a.testtext=

> ASC,a.testdbl ASC LIMIT 1,10;
>
> no. of records=3D0

This is an SQL question. For the sake clarity and a decent answer, you'r=
e =

better of asking this in an SQL group (alt.php.sql comes to mind, if you=
=

use MySQL (I think so, backticks..) comp.databases.mysql is also a good =
=

one).

-- =

Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация