MicroStrategy ONE
Like
Returns TRUE
if a text string matches a specified text pattern; otherwise, returns FALSE
.
Depending on whether you use wildcards and how they are used in the text in the pattern, Like
can be used in place of Begins With
, Ends With
, Contains
, or =
. This operator is used to search for related strings.
Syntax
Arg1
Like
Arg2
Where:
Arg1
and Arg2
must be of data type Text.
Usage Notes
Using wildcards with the Like
operator allows you to search for more than just a static set of text. For example, rather than searching for the exact text pattern South
, you can use wildcards to search for any text pattern that includes South, such as Mid Southern, SouthEast, and South.
The Like
operator can be processed by the MicroStrategy Analytical Engine, or it can be passed to the database to be processed using the database's own comparison support. You can determine if the Like
operator was processed by the MicroStrategy Analytical Engine or passed to the database by viewing the SQL view of a report. If the Like
operator is included in the SQL of the report, the database performed the comparison.
By contrast, if the Like
operator is not included in the SQL of the report, or the Like
operator is part of retrieving results from an Intelligent Cube (see the In-memory Analytics Guide for reporting on Intelligent Cubes), then the MicroStrategy Analytical Engine processed the Like
operator. Wildcard support depends on how the Like
operator is processed:
- If the MicroStrategy Analytical Engine processes the
Like
operator, the following wildcard characters are supported:- The
%
character can be used to represent any number of characters. For example, using the comparisonLike 'Sout%'
returns TRUE for South, SouthEast, and Southern. - The _ character can be used to represent a single character. For example, using the comparison
Like 'Sout_'
returns TRUE for South but returns FALSE for SouthEast and Southern. - The
\
character can be used as an escape character for the%
,_
, or \ characters, which means it can be used prior to these wildcard characters to search for the character rather than to use it as a wildcard. To search for the characters%
,_
, or \, you must include a single\
character before the character you are searching for. For example, to search for the exact textUser_ID
, you would need to use the comparisonLike 'User\_ID'
. - The
*
character can be used to represent any number of characters. For example, using the comparisonLike 'Sout*'
returns TRUE for South, SouthEast, and Southern. The * character also acts as its own escape character, which means it can be used prior to another * to search for asterisks in text patterns. For example, to search for the exact textUser*
, you would need to use the comparisonLike 'User**'
.
- The
- If the database processes the
Like
operator, the database determines how wildcards are supported. In general, many databases support the same wildcard characters and escape characters that are listed above as supported by the MicroStrategy Analytical Engine. However, some databases do not support \ as an escape character and instead use an alternative such as enclosing the wildcard character in brackets. For example, a database may support using[%]
to search for the%
character. Therefore, if theLike
operator is being processed by the database, see your third-party database documentation to verify which wildcards can be used as part of a comparison.
Example
-
Region@DESC like 'South'
Returns TRUE if region is "South".
-
Region@DESC like 'South%'
Returns TRUE if region is "South," "SouthEast," and so on.
-
Region@DESC like '%South%'
Returns TRUE if region is "Mid Southern," "SouthEast," "South," and so on.
-
Region@DESC like 'D_g'
Returns TRUE if region is "Dog," "Dig," "Dug," and so on.
-
Region@DESC like 'D*g'
Returns TRUE if region is "Dog," "Drag," "Drug," and so on.