A simpler solution would be to use regular expressions inside a similar operator. For letters that may be misspelled, you can save variations in the regular expression pattern. For letters matching the z pattern, this is “[زذظض]". You can replace all the letters ز, ذ, ظ, ض with a wildcard, and then query for a similar operator:
select * from searched_table where word like "%[مرى[زذظض%"
After you find all versions of the word you are looking for, you can either show everything to the user or calculate the distance levenshtein (koshinae answer) and show the closest words.
Edit: for letter Z only, the request will look below
set @word = 'مرىض'; -- take this text from user set @word = replace(@word, 'ذ', 'Z'); set @word = replace(@word, 'ظ', 'Z'); set @word = replace(@word, 'ض', 'Z'); set @word = replace(@word, 'ز', 'Z'); set @word = replace(@word, 'Z', '[زظضذ]'); set @word = Concat('%', @word, '%'); select @word; select * from mydb.searchTable where word like @word;
source share