Thursday 9 May 2013

SUBSTRING_INDEX in My-Sql , SUBSTRING_INDEX


SUBSTRING_INDEX(str,delim,count)

Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.


SELECT SUBSTRING_INDEX( INTEREST, '.', 2 ) FROM interest

INTEREST Column Contain:-www.blogger.com

// If You Pass (+ Interger Like here Is 2) Then Return a all String in Left Side. Before 2 delimiter

+-------------------------------------------+

| www.blogger |

+-------------------------------------------+

If You Pass 1 before first delimiter is returned)

+-------------------------------------------+

| www |

+-------------------------------------------+

//If You Reverse Query positive parameter Like(-1) everything to the right of the delimiter is returned.

+-------------------------------------------+

| com |

+-------------------------------------------+

If You Pass -2 before first delimiter is returned)

+-------------------------------------------+

| blogger.com |

+-------------------------------------------+


No comments:

Post a Comment