On Tue, Apr 30, 2013 at 12:52 PM, Staffan Tylen <[email protected]>wrote:

> I have the following two questions to share:
>
> First, assume two tables t1 and t2 where t1 has a text column a with data
> and t2 has a text column p with patterns in LIKE format. For each a in t1 I
> want to find all matching patterns p in t2. Is this possible using a single
> SELECT clause? I've been unable to come up with the expression on the
> right-hand side of LIKE to make this work.
>

SELECT p FROM t1, t2 WHERE t1.a LIKE t2.p;


>
> Second, not having much *NIX knowledge, what's the difference between LIKE
> and GLOB apart from the masking characters and case-sensitivity? The
> documentation doesn't provide much information and Wikipedia shows that
> there are many 'standards' out there. How does GLOB work in SQLite? One or
> two examples of how LIKE and GLOB operate differently would be very
> helpful.
>

LIKE is case insensitive and uses wildcards '%' and '_'

GLOB is case sensitive and uses wildcards '*' and '?'.

GLOB also allows you to say '[abcd]' to mean any character in the set of
"abcd".

LIKE can have an option ESCAPE character for escaping wildcards.  GLOB
cannot.  But with GLOB if you want to match a wildcard character you can
use '[*]' or '[?]'.

Other than that they are the same.  In fact, GLOB and LIKE are implemented
using same subroutine, called with different parameters that determine the
wildcards and case sensitivity.

-- 
D. Richard Hipp
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to