Split text by symbol: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
No edit summary
Line 18: Line 18:


[[Category:Programming]]
[[Category:Programming]]
[[Category:Data Science]]

Revision as of 11:12, 18 April 2015

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))