"Doug" <[EMAIL PROTECTED]> wrote:
> I appologize if this has been answered--haven't found it in the docs, wiki
> or mail archive.
> 
> I have a text column with the following text value in it:
> c:\Temp\Temp1\Audit1.log
> 
> I'm trying to figure out how LIKE works.  When using the following patterns,
> I get the following results:
> 
> '%audit%'     match
> '%\audit%'  non-match
> '%\\audit%' non-match (need a different escape sequence??)
> '%1\audit%'  match (guess don't need an escape sequence after all)
> '%temp1%'   non-match -- huh?
> '%Temp1%'   non-match
> '%\Temp1%'   non-match
> '%Temp1\%'   non-match
> '%p\Temp1%'  match -- starting to think it can't start or end with \ (except
> temp1 case above)
> '%p\Temp1\%' match -- wrong again
> '%p\Temp1\a%' match
> 
> What I'd like to do is let someone enter an arbitrary piece of a filename
> path and find matches.  I'll start experimenting with GLOB, but I expected
> LIKE to be able to do this.
> 
> Can someone help me understand the finer points of LIKE?
> 

When I run these I get a match on every one except '%\\audit%'.
I suspect that you have bugs in whatever program you are using
to run your tests.  Likely the backslashes are being interpreted
as an escape sequence by whatever programming language you are
using before the SQL ever gets to SQLite.

My test script is below.  Try running it using the SQLite shell
and see if you don't get the same answer as I do:

     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%audit%';
     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%\audit%';
     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%\\audit%';
     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%1\audit%';
     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%temp1%';
     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%Temp1%';
     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%\Temp1%';
     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%Temp1\%';
     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%p\Temp1%';
     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%p\Temp1\%';
     SELECT 'c:\Temp\Temp1\Audit1.log' LIKE '%p\Temp1\a%';

--
D. Richard Hipp  <[EMAIL PROTECTED]>


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

Reply via email to