SQLite Tutorial

  • Home
  • Start Here
  • Views
  • Indexes
  • Triggers
  • Functions
    • Aggregate Functions
    • Date Functions
    • String Functions
    • Window Functions
  • API
    • SQLite Python
    • SQLite Node.js
    • SQLite Java
    • SQLite PHP
  • Try It
Home / SQLite Tutorial / SQLite GLOB

SQLite GLOB

Summary: in this tutorial, you will learn how to use the SQLite GLOB operator to determine whether a string matches a specific pattern.

Introduction to the SQLite GLOB operator

The GLOB operator is similar to the LIKE operator. The GLOB operator determines whether a string matches a specific pattern.

Unlike the LIKE operator, the GLOB operator is case sensitive and uses the UNIX wildcards. In addition, the GLOB patterns do not have escape characters.

The following shows the wildcards used with the GLOB  operator:

  • The asterisk (*) wildcard matches any number of characters.
  • The question mark (?) wildcard matches exactly one character.

On top of these wildcards, you can use the list wildcard [] to match one character from a list of characters. For example [xyz] match any single x, y, or z character.

The list wildcard also allows a range of characters e.g., [a-z] matches any single lowercase character from a to z. The [a-zA-Z0-9] pattern matches any single alphanumeric character, both lowercase, and uppercase.

Besides, you can use the character ^ at the beginning of the list to match any character except for any character in the list. For example, the [^0-9] pattern matches any single character except a numeric character.

SQLite GLOB examples

The following statement finds tracks whose names start with the string Man. The pattern Man* matches any string that starts with Man.

SELECT trackid, name FROM tracks WHERE name GLOB 'Man*';
Code language: SQL (Structured Query Language) (sql)

Try It

SQLite GLOB asterisk wildcard example

The following statement gets the tracks whose names end with Man. The pattern *Man matches any string that ends with Man.

SELECT trackid, name FROM tracks WHERE name GLOB '*Man';
Code language: SQL (Structured Query Language) (sql)

Try It

SQLite GLOB asterisk wildcard ending example

The following query finds the tracks whose names start with any single character (?), followed by the string ere and then any number of character (*).

SELECT trackid, name FROM tracks WHERE name GLOB '?ere*';
Code language: SQL (Structured Query Language) (sql)

Try It

SQLite GLOB asterisk wildcard containing example

To find the tracks whose names contain numbers, you can use the list wildcard [0-9] as follows:

SELECT trackid, name FROM tracks WHERE name GLOB '*[1-9]*';
Code language: SQL (Structured Query Language) (sql)

Try It

SQLite GLOB list wildcard example

Or to find the tracks whose name does not contain any number, you place the character ^ at the beginning of the list:

SELECT trackid, name FROM tracks WHERE name GLOB '*[^1-9]*';
Code language: SQL (Structured Query Language) (sql)

Try It

SQLite GLOB list wildcard characters example

The following statement finds the tracks whose names end with a number.

SELECT trackid, name FROM tracks WHERE name GLOB '*[1-9]';
Code language: SQL (Structured Query Language) (sql)

Try It

SQLite GLOB list wildcard numbers example

In this tutorial, you have learned how to use SQLite GLOB operator to test whether a string matches a specific pattern.

  • Was this tutorial helpful ?
  • YesNo
Previous SQLite LIKE
Next SQLite IS NULL

Getting Started

  • What Is SQLite
  • Download & Install SQLite
  • SQLite Sample Database
  • SQLite Commands

SQLite Tutorial

  • SQLite Select
  • SQLite Order By
  • SQLite Select Distinct
  • SQLite Where
  • SQLite Limit
  • SQLite BETWEEN
  • SQLite IN
  • SQLite Like
  • SQLite IS NULL
  • SQLite GLOB
  • SQLite Join
  • SQLite Inner Join
  • SQLite Left Join
  • SQLite Cross Join
  • SQLite Self-Join
  • SQLite Full Outer Join
  • SQLite Group By
  • SQLite Having
  • SQLite Union
  • SQLite Except
  • SQLite Intersect
  • SQLite Subquery
  • SQLite EXISTS
  • SQLite Case
  • SQLite Insert
  • SQLite Update
  • SQLite Delete
  • SQLite Replace
  • SQLite Transaction

SQLite Data Definition

  • SQLite Data Types
  • SQLite Date & Time
  • SQLite Create Table
  • SQLite Primary Key
  • SQLite Foreign Key
  • SQLite NOT NULL Constraint
  • SQLite UNIQUE Constraint
  • SQLite CHECK constraints
  • SQLite AUTOINCREMENT
  • SQLite Alter Table
  • SQLite Rename Column
  • SQLite Drop Table
  • SQLite Create View
  • SQLite Drop View
  • SQLite Index
  • SQLite Expression-based Index
  • SQLite Trigger
  • SQLite VACUUM
  • SQLite Transaction
  • SQLite Full-text Search

SQLite Tools

  • SQLite Commands
  • SQLite Show Tables
  • SQLite Describe Table
  • SQLite Dump
  • SQLite Import CSV
  • SQLite Export CSV

SQLite Functions

  • SQLite AVG
  • SQLite COUNT
  • SQLite MAX
  • SQLite MIN
  • SQLite SUM

SQLite Interfaces

  • SQLite PHP
  • SQLite Node.js
  • SQLite Java
  • SQLite Python

About SQLite Tutorial

SQLite Tutorial website helps you master SQLite quickly and easily. It explains the complex concepts in simple and easy-to-understand ways so that you can both understand SQLite fast and know how to apply it in your software development work more effectively.

Looking for a tutorial…

If you did not find the tutorial that you are looking for, you can use the following search box. In case the tutorial is not available, you can request for it using the request for a SQLite tutorial form.

Recent Tutorials

  • SQLite IIF
  • SQLite Generated Columns
  • SQLite Getting Started
  • SQLite Programming Interfaces
  • SQLite Concat
  • SQLite INSTEAD OF Triggers
  • SQLite Join
  • SQLite IS NULL

Site Links

  • Home
  • About
  • Contact
  • Resources
  • Privacy Policy

Copyright © 2021 SQLite Tutorial. All Rights Reserved.