13

What the difference in the following to query ?

FROM COMPANY WHERE ADDRESS  GLOB '*-*';
FROM COMPANY WHERE ADDRESS  LIKE '%-%';

I know unlike LIKE operator, GLOB is case sensitive. Is it the only difference ?

Saeed Sharman
  • 765
  • 5
  • 24
  • 6
    The other difference is GLOB can be used to search for a range of characters between square brackets, e.g. digits `FROM COMPANY WHERE ADDRESS GLOB '*[0-9]*'` . A more complete answer is here: http://stackoverflow.com/questions/24280980/why-do-we-need-the-glob-clause-in-sqlite – rayzinnz Mar 27 '17 at 01:24

2 Answers2

16

The documentation says:

The GLOB operator is similar to LIKE but uses the Unix file globbing syntax for its wildcards. Also, GLOB is case sensitive, unlike LIKE.

And that's it.

CL.
  • 173,858
  • 17
  • 217
  • 259
3

Other difference that GLOB you can use it as regular expression i.e. : to select fields which end with number use GLOB '*[0-9]'

to select fields which doesn't contain any number use GLOB '[^0-9]

Wael Kabil
  • 31
  • 1