I have a column in my table which has below values and I need the o/p in the following format:
(Example: S-S-661679
. It should in the format S-######
).
The third o/p below is the required o/p in the correct format.
Column Value are like:
'S-S-652235'
'S-xjq113465'
**'S-652235'**
'-641408'
I am using MySQL to query this data from the table. Few columns have the correct value but there are alphabets also and the final o/p should have just S-######. I was thinking of using Regular Expression but could not figure out how to use that in SELECT Clause, all the examples I have seen, I see that it can only be used in WHERE Clause.
I am using below code:
**CONCAT('S-', REPLACE(REPLACE(
seminar_id, ',', ''), 's', ''))**
in the select clause, but it is replicating the 'S-'
which is already present in some columns. I am trying to figure out how to replace multiple 'S-'
and also the alphabetical characters from the values in the columns.
(Example: S-S-661679
. It should in the format S-######
).
The third o/p below is the required o/p in the correct format and the highlighted in the image attached is the correct format.
Column Value are like:
'S-S-652235'
'S-xjq113465'
**'S-652235'**
'-641408'