1

I have a table with an integer value. In my application there is a text field that user enters his desired number to search. If user enter number in English there is no problem. but if his keyboard is not english and enters a number that exists in table mysql doesn't find it. I can't change application to convert user input to english numbers. Is there a way to solve this problem in mysql(config, table structure,etc.)?

for example I have this record in database:

Order_number = 112, ...

If user search for 112 in english, mysql returns the above row. but if user enters 112 for example in persian(۱۱۲) mysql returns an empty set.

user16948
  • 4,801
  • 10
  • 30
  • 41

2 Answers2

1

Not directly.

mysql> SELECT CAST(112 AS CHAR) = '۱۱۲' COLLATE utf8_unicode_ci;
+------------------------------------------------------+
| CAST(112 AS CHAR) = '۱۱۲' COLLATE utf8_unicode_ci    |
+------------------------------------------------------+
|                                                    1 |
+------------------------------------------------------+
1 row in set (0.00 sec)
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
1

Worst case, you could do something like

... where 112 = replace('۱', 1, replace('۲', 2, 'user input here'));

I assume all inputs have 10 distinct digits in their number representations, just that they use different characters to represent the digits.

goat
  • 31,486
  • 7
  • 73
  • 96