Keep in mind that string should be surrounded by
single quotes instead of double quotes:

exact match:

select * from test where filename = 'file';

partial match:

select * from test where filename like '%file%';

Also keep in mind that such a search is CASE SENSITIVE.
There are two solutions to that, either makes the collation
case insensitive or do a:

select * from test where lower(filename) = lower('TESTFILE.txt');

Hower it would be better to do the first lowercase in your
program code when inserting and the second when doing
the select so you don't have to do both in the select.

Rob

p.s. keep in mind that filenames can have single quotes in
them (at least Windows filenames can)! So you should
either call the sqlite interface with parameters (preferred)
or do a search and replace ' with '' in your filenames
before executing either the insert or the select

----- Original Message ----- From: "Martin Engelschalk" <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Monday, December 05, 2005 10:06 AM
Subject: Re: [sqlite] Regarding String Comparision


Hi,

I am not sure if i understand your question right. Perhaps the following will help:

The behaviour depends on the comparison operator.

If you do

select ...
from FileTable
where FileName = "testfile.txt"

then the whole string will be matched

If you do

select ...
from FileTable
where FileName like "%/testfile.txt"

then you would get all files named "testfile.txt" regardless of their path. sqlite will search for strings ending in "/testfile.txt".

Martin

Ritesh Kapoor schrieb:

Hi,

I am debugging a program which has a FileTable field called FileName
declared as-

"FileName  varchar(1024) primary key"

It stores filenames including their paths e.g. - "myDir1/testfile.txt"

If I were to search in this FileTable in the column FileName for a
string "testfile.txt" would it return me the row "myDir1/testfile.txt"?

I'm not sure about this but currently I think this is what is
happening. Is this the default behavior of SQLite?
Are there any setting which would make it match the whole string?  So
that I don't have ambigious situations where two rows might match to the
same search string.

Thanks & Regards,
ritesh

Reply via email to