php - Get the data between two hyphens from mysql database -


I want to get the value between two hyphens from one variable.

For example:

  1) H-AG -1987 2) GN-RV-0001  < / Pre> 

From the top, I want to display:

1) AG and

2)

use substring_index () :

Select
  substring_index (substring_index (col, '-', 2), '-', -1) as second value  

Comments