All Products
Search
Document Center

MaxCompute:LIKE

Last Updated:May 16, 2025

LIKE is an operator used for SQL pattern matching. It is typically used with the WHERE clause of a SELECT statement to filter string data that matches a specific pattern. This topic describes common wildcard characters in LIKE and provides examples of how to use them.

Precaution

MaxCompute SQL supports only the UTF-8 character set. If data is encoded in other formats, the calculation results may be incorrect.

LIKE wildcard characters

  • % matches any number of characters.

  • _ matches a single character.

If you want to match the % or _ character itself, you must escape it. For example: \\% matches the character %. \\_ matches the character _.

Examples

  • Example 1: The result is true.

    select 'abcd' like 'ab%'; 
  • Example 2: The result is false.

    select 'abcd' like 'ab_';
  • Example 3: The result is true.

    select 'ab_cde' like 'ab\\_c%';

References

For more precise character matching or replacement, see RLIKE.