Home  >  Article  >  Database  >  What does arbitrary character represent in sql?

What does arbitrary character represent in sql?

下次还敢
下次还敢Original
2024-05-01 23:45:27664browse

The wildcard character representing any character in SQL is the percent sign (%). It can be placed at the beginning, end, or middle of a pattern string to match characters at the beginning, end, or inclusion of the specified string.

What does arbitrary character represent in sql?

What is the wildcard representing any character in SQL

In SQL, the wildcard character representing any character is percent Number(%).

How to use the percent sign wildcard character

The percent sign wildcard character can be placed at the beginning, end, or middle of the pattern string.

  • Starting position: Matches all values ​​starting with the specified string. For example, �c matches any value that begins with "abc".
  • Ending position: Matches all values ​​ending with the specified string. For example, abc% matches any value that ends with "abc".
  • Middle position: Matches all values ​​that contain the specified string. For example, �c% matches all values ​​that contain the "abc" substring.

Example

  • SELECT * FROM table_name WHERE column_name LIKE '%john%' Matches all subtitles containing "john" The column_name column of the row of strings.
  • SELECT * FROM table_name WHERE column_name LIKE 'a%b%' Matches the column_name column of all rows that begin with "a" and end with "b".
  • SELECT * FROM table_name WHERE column_name LIKE '%' Matches the column_name column of all rows (because any string contains the empty string).

Note:

The percent wildcard is not case-sensitive and can be used with other wildcards, such as the underscore (_), which matches a single character .

The above is the detailed content of What does arbitrary character represent in sql?. 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