On 3/09/2007 1:00 AM, RaghavendraK 70574 wrote:
Hi,

create table test (column text);

Please try pasting in SQL that actually runs. "column" is a reserved word.

create index idx on text(column);[IN uses index]

Please try pasting in SQL that actually runs. You need "test", not "text". Use -- for comments.

insert into test values ('9');
insert into test values ('98');
insert into test values ('985');

My Query: see if u have any record
98451234 which has a similar pattern.

The literal answer to that is a boolean, not one row.

select * from test where column in ('98451234','9845123','984512','98451',
 '9845','984','98','9','-1') limit 1;

even when limit 1 is provided it continues to search.

You don't want the FIRST, you want the LONGEST.
8<--- ragha.sql
create table test (acol text, guff integer);
create index idx on test(acol);
insert into test values ('9', 1);
insert into test values ('98', 42);
insert into test values ('98', 43);
insert into test values ('985', 666);
select * from test t where length(t.acol) = (
    select max(length(ty.rescol)) from (
select tx.acol as rescol from test tx where tx.acol in ('98451234','9845123','984512','98451', '9845','984','98','9','')
        ) ty
    );
8<---

Result:
sqlite> .read ragha.sql
98|42
98|43
sqlite>


Pls suggest a better way.


Get your head out of the VDBE. Your problem is nothing to do with telling the VDBE what to do. It's not even anything to do with sqlite. Your problem is that SQL is not suited for the type of processing that you are trying to do. If you have to fight a language to the extent that you are doing, you are using the wrong language. If you must experiment with fancy indexing or fuzzy matching or whatever, use ODBC to an sqlite database from an easy-to-use language like Python. Instead of one humungous query, try a 3-step exercise: (query , process results with Python, 2nd query to get result rows).

HTH,
John

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to