Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between LIKE and GLOB in SQLite?

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 ?

like image 581
Saeed Sharman Avatar asked May 29 '16 10:05

Saeed Sharman


People also ask

What is GLOB SQLite?

SQLite GLOB operator is used to match only text values against a pattern using wildcards. If the search expression can be matched to the pattern expression, the GLOB operator will return true, which is 1. Unlike LIKE operator, GLOB is case sensitive and it follows syntax of UNIX for specifying THE following wildcards.

Does SQLite support like?

The SQLite LIKE condition allows wildcards to be used in the WHERE clause of a SELECT, INSERT, UPDATE, or DELETE statement. This allows you to perform pattern matching.

Is there an if statement in SQLite?

Overview of SQLite IIF() function In practice, you use the IIF() function to add the if-else logic to queries to form more flexible queries.

Is SQLite case sensitive?

For one thing, databases vary considerably in how they handle text; for example, while some databases are case-sensitive by default (e.g. Sqlite, PostgreSQL), others are case-insensitive (SQL Server, MySQL).


2 Answers

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]

like image 162
Wael Kabil Avatar answered Oct 10 '22 10:10

Wael Kabil


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.

like image 37
CL. Avatar answered Oct 10 '22 11:10

CL.