C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
SQLite LIKE Clause (Operator)The SQLite LIKE operator is used to match text values against a pattern using wildcards. In the case search expression is matched to the pattern expression, the LIKE operator will return true, which is 1. There are two wildcards used in conjunction with the LIKE operator:
The percent sign represents zero, one, or multiple numbers or characters. The underscore represents a single number or character. Syntax: SELECT FROM table_name WHERE column LIKE 'XXXX%' or SELECT FROM table_name WHERE column LIKE '%XXXX%' or SELECT FROM table_name WHERE column LIKE 'XXXX_' or SELECT FROM table_name WHERE column LIKE '_XXXX' or SELECT FROM table_name WHERE column LIKE '_XXXX_' Here, XXXX could be any numeric or string value. Example: We have a table named 'STUDENT' having following data: In these examples the WHERE statement having different LIKE clause with '%' and '_' operators and operation is done on 'FEES':
Example1: Select all records from STUDENT table WHERE age start with 2. SELECT * FROM STUDENT WHERE AGE LIKE '2%'; Output: Example2: Select all records from the STUDENT table WHERE ADDRESS will have "a" (a) inside the text: SELECT * FROM STUDENT WHERE ADDRESS LIKE '%a%'; Output:
Next TopicSQLite Glob Clause
|