gpt4 book ai didi

mysql - 除了字符串的第一个字符之外,如何在 mysql 中区分大小写?

转载 作者:行者123 更新时间:2023-11-29 12:29:26 25 4
gpt4 key购买 nike

如何在 mysql 中区分大小写,除了字符串的第一个字符?

示例:

字符串:ABC12345

  • aBC12345:好的
  • abc12345:否
  • ABc12345:否

最佳答案

您可以使用REGEXP :

select * from mytable where binary myfield REGEXP '^[aA]BC12345$';

记下:

The REGEXP and RLIKE operators work in byte-wise fashion, so they are not multibyte safe and may produce unexpected results with multibyte character sets. In addition, these operators compare characters by their byte values and accented characters may not compare as equal even if a given collation treats them as equal.

查看sqlfiddle .

关于mysql - 除了字符串的第一个字符之外,如何在 mysql 中区分大小写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27790305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com