ragha, you want something to give you a 'best match'. The 'like' operator in the way you are using it does not do that, but it IS working as it should.
I am not sure how to make it any clearer. Rgds, Simon On 29/08/2007, RaghavendraK 70574 <[EMAIL PROTECTED]> wrote: > > Hi, > > Pls see my last post, hope it is clear. > > regards > ragha > ****************************************************************************************** > This email and its attachments contain confidential information from HUAWEI, > which is intended only for the person or entity whose address is listed > above. Any use of the information contained herein in any way (including, but > not limited to, total or partial disclosure, reproduction, or dissemination) > by persons other than the intended recipient(s) is prohibited. If you receive > this e-mail in error, please notify the sender by phone or email immediately > and delete it! > > ***************************************************************************************** > > ----- Original Message ----- > From: Igor Tandetnik <[EMAIL PROTECTED]> > Date: Wednesday, August 29, 2007 7:57 pm > Subject: [sqlite] Re: BestMatch and SqliteStatment Clash > > > RaghavendraK 70574 > > <[EMAIL PROTECTED]> wrote: > > > Best match is "9854002656" among the 2 records. > > > > > > Pls try this simple one.It will make it clear, > > > > > > create table test(t text); > > > > > > insert into test values ('9'); > > > insert into test values('98'); > > > insert into test values('983'); > > > insert into test values('9854'); > > > > > > select * from test where '982' like t || '%' order by t desc > > limit 1; > > > > > > above sql tries to model a DST(digit search tree). > > > Expected output: 98 > > > > > > This works but will not work for earlier data(9854002656).So > > seems to > > > be bug. > > > > The expression ('982' like '98%') evaluates to true. The expression > > ('982' like '9854002656%') evaluates to false. LIKE operator > > behaves > > correctly in both cases. There is no bug, just a case of > > unrealistic > > expectations and/or wishful thinking on your part. > > > > It's not clear what your definition of a "best match" is, but it's > > obvious that the test you put into the SELECT statement is not it. > > Computers have this nasty annoying habit of doing what you tell > > them to > > do, not what you want them to do. If you describe the metric you > > want to > > use to determine the "best" match, perhaps someone would help you > > design > > a statement that would implement it. > > > > Igor Tandetnik > > > > > > -------------------------------------------------------------------- > > --------- > > To unsubscribe, send email to [EMAIL PROTECTED] > > -------------------------------------------------------------------- > > --------- > > > > > > ----------------------------------------------------------------------------- > To unsubscribe, send email to [EMAIL PROTECTED] > ----------------------------------------------------------------------------- > > ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------