Home  >  Article  >  Database  >  How to use like in oracle

How to use like in oracle

下次还敢
下次还敢Original
2024-05-02 23:09:33841browse

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.

How to use like in oracle

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>
The following example finds all names containing "smith" " or "jones":

<code>SELECT employee_name
FROM employees
WHERE employee_name LIKE '%smith%' OR employee_name LIKE '%jones%';</code>
The following example finds all product names that do not begin with "A":

<code>SELECT product_name
FROM products
WHERE product_name NOT LIKE 'A%';</code>

Note:

    The LIKE clause is not case-sensitive unless the COLLATE clause is used to specify a specific character set and collation.
  • You can use the ESCAPE clause to escape wildcard characters so that they match literally.

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:trunc usage in oracleNext article:trunc usage in oracle