In Oracle, LIKE operator allows you to perform pattern matching search in a column. The Oracle LIKE operator can be used with SELECT, INSERT, UPDATE and DELETE statement with the combination of WHERE clause.
The percent (%) sign represents zero, one, or multiple characters and underscore (_) represents a single character.
LIKE Operator | Description |
---|---|
WHERE Address LIKE 'c%' | Finds field values starts with "c" |
WHERE Address LIKE '%c' | Finds field values ends with "c" |
WHERE Address LIKE '%and%' | Finds field values that have "and" in any position |
WHERE Address LIKE '_2%' | Finds field values that have "2" in the second position |
WHERE Address LIKE 'c%z' | Finds Finds values that starts with "a" and ends with "z" |
To search a record based on pattern matching use LIKE operator, use the following syntax:
Parameters:
tablename: The table name from which you want to fetch the records.
pattern: To perform pattern matching search in a column.
Note:
In the above example, we are showing how to use the LIKE operator to search a "address" starting with '12-13'.
Note:
In the above example, we are showing how to use the LIKE operator to search a "address" ending with 'Bhopal'.
Note:
In the above example, we are showing how to use the LIKE operator using underscore (_) to search a address that have "2" in the second position with SELECT statement.