contains Function
The contains function indicates whether or not a search string is present inside the source string.
Syntax
returnvalue contains(source, search_string)
source ::= any*
search_string ::= any*
returnvalue ::= boolean
Semantics
- source
-
The input string to be searched. This argument is implicitly cast to a sequence of strings.
- search_string
-
The string that should be searched in the source. This argument is implicitly cast to a sequence of strings.
- returnvalue
-
Returns true if search_string exists inside source else returns false.
Returns false if any argument is an empty sequence or a sequence with more than one item.
Returns NULL if source or search_string argument is NULL.
Example 12-46 contains Function
In this example, the firstname field values that contain the string "ar" in it is indicated as true.
SELECT firstname, contains(firstname,"ar") FROM users
Output: +-----------+----------+
| firstname | Column_2 |
+-----------+----------+
| John | false |
| Peter | false |
| Mary | true |
+-----------+----------+