ENDSWITH()

Description

Returns whether to end with the specified suffix. Returns 1 if the string ends with the specified suffix, otherwise it returns 0. This function is case sensitive.

Syntax

  1. > ENDSWITH(str,suffix)

Arguments

ArgumentsDescription
strRequired. CHAR and VARCHAR both are supported.
suffixRequired. CHAR and VARCHAR both are supported.

Returned Values

  • 1, if the string ends with the specified suffix.
  • 0, if the string does not end with the specified suffix.

Examples

  1. > drop table if exists t1;
  2. > create table t1(a int,b varchar(100),c char(20));
  3. > insert into t1 values
  4. (1,'Ananya Majumdar', 'XI'),
  5. (2,'Anushka Samanta', 'X'),
  6. (3,'Aniket Sharma', 'XI'),
  7. (4,'Anik Das', 'X'),
  8. (5,'Riya Jain', 'IX'),
  9. (6,'Tapan Samanta', 'XI');
  10. > select a,endsWith(b,'a') from t1;
  11. +------+----------------+
  12. | a | endswith(b, a) |
  13. +------+----------------+
  14. | 1 | 0 |
  15. | 2 | 1 |
  16. | 3 | 1 |
  17. | 4 | 0 |
  18. | 5 | 0 |
  19. | 6 | 1 |
  20. +------+----------------+
  21. > select a,b,c from t1 where endswith(b,'a')=1 and endswith(c,'I')=1;
  22. +------+---------------+------+
  23. | a | b | c |
  24. +------+---------------+------+
  25. | 3 | Aniket Sharma | XI |
  26. | 6 | Tapan Samanta | XI |
  27. +------+---------------+------+

Constraints

Currently, MatrixOne doesn’t support select function() without from tables.