Case-insensitive REPLACE in MySQL?

后端 未结 8 2147
無奈伤痛
無奈伤痛 2020-12-05 10:00

MySQL runs pretty much all string comparisons under the default collation... except the REPLACE command. I have a case-insensitive collation and need to run a

8条回答
  •  攒了一身酷
    2020-12-05 10:49

    In case of 'special' characters there is unexpected behaviour:

    SELECT case_insensitive_replace('A', 'Ã', 'a')
    

    Gives

    a
    

    Which is unexpected... since we only want to replace the à not A

    What is even more weird:

    SELECT LOCATE('Ã', 'A');
    

    gives

    0
    

    Which is the correct result... seems to have to do with encoding of the parameters of the stored procedure...

提交回复
热议问题