Case-insensitive REPLACE in MySQL?

后端 未结 8 2094
無奈伤痛
無奈伤痛 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:31

    I went with http://pento.net/2009/02/15/case-insensitive-replace-for-mysql/ (in fvox's answer) which performs the case insensitive search with case sensitive replacement and without changing the case of what should be unaffected characters elsewhere in the searched string.

    N.B. the comment further down that same page stating that CHAR(255) should be changed to VARCHAR(255) - this seemed to be required for me as well.

提交回复
热议问题