Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 



SUBSTRING_INDEX Function

Description

The SUBSTRING_INDEX function counts the separators included in the partial character string and will return the partial character string before countth. The return value is a VARCHAR type.

Syntax

SUBSTRING_INDEX (string, delim, count)

  • string : Input character string. The maximum length is 33,554,432 and if this length is exceeded, NULL will be returned.
  • delim : Delimiter. It is case-sensitive.
  • count : Delimiter occurrence count. If you enter a positive number, it counts the character string from the left and if you enter a negative number, it counts it from the right. If it is 0, an empty string will be returned. If the type cannot be converted, an error wll be returned.
Example

SELECT SUBSTRING_INDEX('www.cubrid.org','.','2');

  substring_index('www.cubrid.org', '.', '2')

======================

  'www.cubrid'

 

SELECT SUBSTRING_INDEX('www.cubrid.org','.','2.3');

  substring_index('www.cubrid.org', '.', '2.3')

======================

  'www.cubrid'

 

SELECT SUBSTRING_INDEX('www.cubrid.org',':','2.3');

  substring_index('www.cubrid.org', ':', '2.3')

======================

  'www.cubrid.org'

 

SELECT SUBSTRING_INDEX('www.cubrid.org','cubrid',1);

  substring_index('www.cubrid.org', 'cubrid', 1)

======================

  'www.'

 

SELECT SUBSTRING_INDEX('www.cubrid.org','.',100);

  substring_index('www.cubrid.org', '.', 100)

======================

  'www.cubrid.org'