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