You can use SUBSTRING_INDEX to return occurrences after the delimiter, if the counter is positive returns occurrences from left to end of string, if negative returns from right.
SUBSTRING_INDEX(string,delimitador,contador)
Example:
SELECT SUBSTRING_INDEX('Informacoes - Separadas - Por - Hifen', '-', 1) as texto;
Returns:
Informacoes
Example 2:
SELECT SUBSTRING_INDEX('Informacoes - Separadas - Por - Hifen', '-', 2) as texto;
Returns:
Informacoes - Separadas
Example 3:
SELECT SUBSTRING_INDEX('Informacoes - Separadas - Por - Hifen', '-', -2) as texto;
Returns:
Por - Hifen
To return Informacoes Separadas
without the hyphen, you can use a combination of SUBSTRING_INDEX
and CONCAT:
SELECT
CONCAT(
SUBSTRING_INDEX(
SUBSTRING_INDEX('Informacoes - Separadas - Por - Hifen', '-', 2),'-',1
),
SUBSTRING_INDEX(
SUBSTRING_INDEX('Informacoes - Separadas - Por - Hifen', '-', 2),'-',-1
)
) as texto;
What’s the name of the tabel and the column, just to try to help you accordingly
– Miguel
Whatever, you can call it
Texto from tabela
or just useselect "Informacoes - Separadas - Por - Hifen";
even.– Daniel Dutra