How do I convert a column to ASCII on the fly without saving to check for matches with an external ASCII string?

前端 未结 4 1342
夕颜
夕颜 2021-01-19 09:25

I have a member search function where you can give parts of names and the return should be all members having at least one of username, firstname or lastname matching that i

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-19 09:45

    The CAST() operator in the context of character encodings translates from one method of character storage to another — it does not change the actual characters, which is what you are after. An é character is what it is in any character set, it is not an e. You need to convert accented characters to non-accented characters, which is a different issue and has been asked a number of times previously (normalizing accented characters in MySQL queries).

    I am unsure if there is a way to do this directly in MySQL, short of having a translation table and going through letter by letter. It would most likely be easier to write a PHP script to go through the database and make the translations.

提交回复
热议问题