0

I have prices stored as varchar written in Indian numbers, e.g. '١٨٠٠'. Is there a way to convert these data to standard integers e.g. 1800?

input table

|price|
|١٨٠٠ |
|200  |

output table

|price|
|1800 |
|200  |

I tried FOMAT() with en_US locale but it returns zero

Diaa Saada
  • 1,026
  • 1
  • 12
  • 22

1 Answers1

3

If the value is clear indian number, without additional symbols, then use

SELECT UNHEX(REPLACE(HEX(indian_value), @prefix, '3')) AS arabic_value

For the symbols in your sample data @prefix = 'D9A'.

fiddle

Akina
  • 39,301
  • 5
  • 14
  • 25