【问题标题】:Having trouble with MySQL wildcard charactersMySQL通配符有问题
【发布时间】:2021-09-17 08:57:50
【问题描述】:

我按照 w3schools 上的说明进行操作,但似乎无法正常工作。我不断得到结果“空集”,即使看起来应该返回多个名称,因为有名称以 a、l 和 c 开头。

顺便说一句,我正在通过 Mac 上的终端使用 MySQL。谢谢。

here is a picture of the table I'm using

这是我的语法 -

mysql> select * from Student where Name like '[alc]%';

【问题讨论】:

    标签: mysql macos wildcard


    【解决方案1】:

    通过您的选择,您可以搜索与“[alc]”完全匹配的模式 后跟以 % 表示的任何内容。

    试试这样的正则表达式。

     select * from Student where Name regexp '^(a|l|c)';
    

    这将为您提供以给定字母开头的名称,不区分大小写

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多