sqlite
Database; use; embedded relational database
glob
英[glɒb] 美[glɑ :b]
n. A drop, a small drop of water, a ball (of plastic material)
SQLite Glob functions syntax
Function:SQLite's GLOB operator is used to match the text value of the wildcard specified pattern. If the search expression matches the pattern expression, the GLOB operator returns true, which is 1. Unlike the LIKE operator, GLOB is case-sensitive and follows UNIX syntax for the following wildcard characters. Asterisk (*) Question mark (?) Asterisk (*) represents zero, one or more numbers or characters. The question mark (?) represents a single number or character. These symbols can be used in combination.
Syntax: * and ? The basic syntax is as follows:
SELECT FROM table_name
WHERE column GLOB 'XXXX*'
or
SELECT FROM table_name
WHERE column GLOB '*XXXX*'
or
SELECT FROM table_name
WHERE column GLOB 'XXXX?'
or
SELECT FROM table_name
WHERE column GLOB '? XXXX'
or
SELECT FROM table_name
WHERE column GLOB '?XXXX?'
or
SELECT FROM table_name
WHERE column GLOB '????'
You can combine N number of conditions using AND or OR operators. Here, XXXX can be any number or string value.
SQLite Glob functions example
COMPANY 表有以下记录: ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 1 Paul 32 California 20000.0 2 Allen 25 Texas 15000.0 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 5 David 27 Texas 85000.0 6 Kim 22 South-Hall 45000.0 7 James 24 Houston 10000.0 COMPANY 表中 AGE 以 2 开头的所有记录: sqlite> SELECT * FROM COMPANY WHERE AGE GLOB '2*'; 这将产生以下结果: ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 2 Allen 25 Texas 15000.0 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 5 David 27 Texas 85000.0 6 Kim 22 South-Hall 45000.0 7 James 24 Houston 10000.0 COMPANY 表中 ADDRESS 文本里包含一个连字符(-)的所有记录: sqlite> SELECT * FROM COMPANY WHERE ADDRESS GLOB '*-*'; 这将产生以下结果: ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 4 Mark 25 Rich-Mond 65000.0 6 Kim 22 South-Hall 45000.0