Home > Back-end >  '%' express any characters, is there any special character for only one character?
'%' express any characters, is there any special character for only one character?

Time:06-14

In Oracle '%' stands for any characters in that position. Example:

Select * from table where id like '%1'

This stands for anything behind the number 1 : XXXXXXXXXXXX1 99999999991.

Is there any other character to express only 1 character ?.

Example of what I mean: (im going to use ~ as that reserved character)

Select * from table where id like '~1'

In this case only 91, x1, X1... etc would enter the select, but XX1 woudn't as you only used one ~.

Select * from table where id like '~~~1'

xxx1, 9991, 8881, etc....

Hope I explained myself, english is not my native language.

CodePudding user response:

Only one wildcard character is represented by underscore, _

CodePudding user response:

You can refer to Oracle's LIKE condition documentation:

like_condition::=

LIKE condition syntax

In this syntax:

  • char1 is a character expression, such as a character column, called the search value.
  • char2 is a character expression, usually a literal, called the pattern.
  • esc_char is a character expression, usually a literal, called the escape character.

[...]

The pattern can contain special pattern-matching characters:

  • An underscore (_) in the pattern matches exactly one character (as opposed to one byte in a multibyte character set) in the value.
  • A percent sign (%) in the pattern can match zero or more characters (as opposed to bytes in a multibyte character set) in the value. The pattern '%' cannot match a null.

Use an _ underscore.

  • Related