I have a data as follows
+-------+----------------------------------------------+
| ID | COMMENT |
+-------+----------------------------------------------+
| 3118- | Replace Id.NO 3117-52-96 Was wrongly updated |
+-------+----------------------------------------------+
| 4857 | Replace Id.NO.4875-21-96-due to 2 mistake |
+-------+----------------------------------------------+
| 5877 | replace .ID NO 5876.69.49 due mistake 101 |
+-------+----------------------------------------------+
| 1254 | Replace Id No. 1259-93-87 due to mistake 81 |
+-------+----------------------------------------------+
I want to get the values after the No and before some words. Something like below
+-------+----------------------------------------------+------------+
| ID | COMMENT | NEW_VALUE |
+-------+----------------------------------------------+------------+
| 3118- | Replace Id.NO 3117-52-96 Was wrongly updated | 3117-52-96 |
+-------+----------------------------------------------+------------+
| 4857 | Replace Id.NO.4875-21-96-due to mistake | 4875-21-96 |
+-------+----------------------------------------------+------------+
| 5877 | replace .ID NO 5876.69.49 due mistake | 5876.69.49 |
+-------+----------------------------------------------+------------+
| 1254 | Replace Id No. 1259-93-87 due to mistake | 1259-93-87 |
+-------+----------------------------------------------+------------+
Then I have to update the ID column with NEW_VALUE. Once I get the NEW_VALUE, it will be easy to update.
What I have tried.
SELECT ID,COMMENT,
REPLACE(REPLACE(COMMENT,'Replace Id.NO',''),'Replace Id.NO.','')FROM MYTABLE
Like above i'm using multiple(around 10) REPLACE to get my required value. I'm sure there should be some easy way.
No.-and.are ok. What about/or' '(a single white space)? if' 'is "ok", what would you expect to see if something like the string'Replace ID no 123 456 789 2 orders were wrong'? Is a "No" always 3 blocks of numbers?