There are also !~~ and !~~* operators that represent NOT LIKE and NOT ILIKE, respectively. The operator ~~ is equivalent to LIKE, and ~~* corresponds to ILIKE. This is not in the SQL standard but is a PostgreSQL extension. The key word ILIKE can be used instead of LIKE to make the match case-insensitive according to the active locale. This effectively disables the escape mechanism, which makes it impossible to turn off the special meaning of underscore and percent signs in the pattern. It's also possible to select no escape character by writing ESCAPE ''. (But it is still special to the string literal parser, so you still need two of them.) You can avoid this by selecting a different escape character with ESCAPE then a backslash is not special to LIKE anymore. Thus, writing a pattern that actually matches a literal backslash means writing four backslashes in the statement. Note that the backslash already has a special meaning in string literals, so to write a pattern constant that contains a backslash you must write two backslashes in an SQL statement. To match the escape character itself, write two escape characters. The default escape character is the backslash but a different one may be selected by using the ESCAPE clause. To match a literal underscore or percent sign without matching other characters, the respective character in pattern must be preceded by the escape character. To match a sequence anywhere within a string, the pattern must therefore start and end with a percent sign. ![]() LIKE pattern matches always cover the entire string. Some examples: 'abc' LIKE 'abc' true'abc' LIKE 'a%' true'abc' LIKE '_b_' true'abc' LIKE 'c' false An underscore ( _) in pattern stands for (matches) any single character a percent sign ( %) matches any string of zero or more characters. ![]() ![]() If pattern does not contain percent signs or underscore, then the pattern only represents the string itself in that case LIKE acts like the equals operator. An equivalent expression is NOT ( string LIKE pattern).) (As expected, the NOT LIKE expression returns false if LIKE returns true, and vice versa. The LIKE expression returns true if the string is contained in the set of strings represented by pattern. LIKE string LIKE pattern string NOT LIKE pattern Įvery pattern defines a set of strings.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |