I have a column which value is combine two elements, Just like "Class_Name"。For example , "Websites_Google"。But for some historical reasons, there have some special value which have no "Class_" prefix, like "yahoo".
Now I need to extract the class from columns. If there is no "class_" prefix , i expect return "" . I just try SUBSTRING_INDEX functions like this:
select SUBSTRING_INDEX(column1, '_', 1) .......
It works very well when the value have "class_", but in the no "class_" situation, it return the whole value, "yahoo" return "yahoo", not the empty string which i want.
How to solve it?