Home > Database > Oracle > body text

How to use like in oracle

下次还敢
Release: 2024-05-02 23:09:33
Original
882 people have browsed it

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>
Copy after login

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>
Copy after login
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>
Copy after login
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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template