LIKE Condition


 

SQLite: LIKE Condition

This SQLite tutorial explains how to use the SQLite LIKE condition to perform pattern matching with syntax and examples.

 

Description:
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.

 
Syntax:

 

Parameters or Arguments:

expressions

A character expression such as a column or field.

pattern

A character expression that contains pattern matching. The patterns that you can choose from are:

Wildcard Explanation
% Allows you to match any string of any length (including zero length)
_ Allows you to match on a single character

 

Examples:

  • The following SQL statement selects all employee’s with a position starting with the letter “d”:

    id name position hire_date
    100 chiru developer 1/1/2014
    103 nithya developer 6/1/2013
    104 jaya developer 1/1/2014
    105 uma designer 1/1/2013
  • The following SQL statement selects all employee’s with a position starting with the letter “dev”:

    id name position hire_date
    100 chiru developer 1/1/2014
    103 nithya developer 6/1/2013
    104 jaya developer 1/1/2014
  • The following SQL statement selects all employee’s with a position starting with the letter “d” and ends with letter “er”:

    id name position hire_date
    100 chiru developer 1/1/2014
    103 nithya developer 6/1/2013
    104 jaya developer 1/1/2014
    105 uma designer 1/1/2013
  • The following SQL statement selects all employee’s with a name containing the pattern “th”:

    id name position hire_date
    103 nithya developer 6/1/2013
    106 mathu research analyst 1/1/2013
    107 anitha research analyst 1/1/2014
  • The following SQL statement selects all employee’s with a name not containing the pattern “th”:

    id name position hire_date
    100 chiru developer 1/1/2014
    101 arunesh manager 1/1/2012
    102 naga Team Lead 1/1/2013
    104 jaya developer 1/1/2014
    105 uma designer 1/1/2013
    108 kannan 6/1/2013
    109 deepak