Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

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



The POSITION function returns the position of a character string corresponding to substring within a character string corresponding to string. Note that it returns the position in bytes, not in characters. Therefore, the return values may differ because the number of bytes representing a single character is different in multi-byte character sets.

An expression that returns a character string or a bit string can be specified as an argument of this function. The return value is an integer greater than or equal to 0. This function returns the position value in bytes for a character string, and in bits for a bit string.

The POSITION function is occasionally used in combination with other functions. For example, if you want to extract a certain string from another string, you can use the result of the POSITION function as an input to the SUBSTRING function.


POSITION ( substring IN string )


substring :

bit string

character string


  • substring : Specifies the character string whose position is to be returned. If the value is an empty character, 1 is returned. If the value is NULL, NULL is returned.

--character set is euc-kr for Korean characters


--it returns 1 when substring is empty space

SELECT POSITION ('' IN '12345abcdeabcde');

  position('' in '12345abcdeabcde')




--it returns position of the first 'b'

SELECT POSITION ('b' IN '12345abcdeabcde');

  position('b' in '12345abcdeabcde')




-- it returns position of the first '나' on double byte charset

SELECT POSITION ('나' IN '12345가나다라마가나다라마');

  position('나' in '12345가나다라마가나다라마')




--it returns 0 when no substring found in the string

SELECT POSITION ('f' IN '12345abcdeabcde');

  position('f' in '12345abcdeabcde')




SELECT POSITION (B'1' IN B'000011110000');

  position(B'1' in B'000011110000')