Search code examples
mysqlsqlmysql-workbenchinfinidb

How can i get middle values in particular column in SQL


How can i get middle values in particular column in SQL 5.6, MySQL Workbench ie :

5014.**160201**.1200.1-2 here i need the value **160201**


Solution

  • You can get the second value, based on the period separator, using substring_index():

    select substring_index(substring_index(col, '.', 2), '.', -1) as second_part