The LIKE clause is used to find a string pattern in a table that contains a specific sequence of characters by specifying the pattern wildcard characters percent sign (%) and underscore (_) to match character sequences and single characters. It also allows the use of square brackets to specify character sets and exclude character sets, as well as the use of escape characters to escape wildcards for literal matching.
Usage of LIKE clause in Oracle
The LIKE clause is used to match string patterns. It is used to find rows in a table that contain a specific sequence or pattern of characters.
Syntax:
<code>SELECT column_name FROM table_name WHERE column_name LIKE pattern;</code>
Where:
column_name
: The column name to be searched. pattern
: The string pattern to match. Pattern wildcard:
: Matches any sequence of characters (including the empty string).
: Matches any single character.
: Matches the character set specified within square brackets.
: Matches unspecified character sets within square brackets.
Usage example:
The following example finds all customer names starting with "J":<code>SELECT customer_name FROM customers WHERE customer_name LIKE 'J%';</code>
<code>SELECT employee_name FROM employees WHERE employee_name LIKE '%smith%' OR employee_name LIKE '%jones%';</code>
<code>SELECT product_name FROM products WHERE product_name NOT LIKE 'A%';</code>
Note:
The above is the detailed content of How to use like in oracle. For more information, please follow other related articles on the PHP Chinese website!