-1

Here is my string column with value for ex:

Customer: check, ID: 3963f4bb-59fb-4a26, NAME: TAMIL

I want only the value of "3963f4bb-59fb-4a26" which is in between start of "ID: " and end keyword of ", ".

Please anyone suggest how to extract only that ID value.

The length of string may not be same and values inside may in mixed format also, so based on ID I wants to extract that string.

I tried using substring, but not able to extract result.

1 Answers1

0

You can do it using SUBSTRING_INDEX :

select description, SUBSTRING_INDEX(SUBSTRING_INDEX(description, 'ID:', -1), ',', 1) as snippet
from my_table;

Check it here : https://dbfiddle.uk/K5FNq-EY

SelVazi
  • 10,028
  • 2
  • 13
  • 29
  • Hi SelVazi, Thanks for the quick reply. The solution is Really superb one. While I tried to implement the same in my sql server and I faced the issue like "substring_index' is not a recognized built-in function name". I think in sql server "substring_index" is not a in built function. Need to modify the query which in compliance with sql server. – Kesavan Balakrishnan Jan 04 '23 at 09:06
  • Have a look here : https://stackoverflow.com/questions/23854724/sql-server-equivalent-of-substring-index-function-in-mysql – SelVazi Jan 04 '23 at 09:11