Split text by symbol

From LemonWiki共筆
Revision as of 11:11, 18 April 2015 by Planetoid (talk | contribs)
Jump to navigation Jump to search

Split text by symbol (delimiter / separator)

Approachs

Example

Task: Split 25.040215, 121.512532 by the comma ( , )

Expected output:

  • 25.040215
  • 121.512532

MySQL Approach

  1. How to get the first string ( 25.040215 ): SELECT TRIM(SUBSTRING_INDEX('25.040215, 121.512532' ,',', 1))
  2. How to get the second string ( 121.512532 ): SELECT TRIM(SUBSTRING_INDEX('25.040215, 121.512532' ,',', -1))