【问题标题】:How to select the total number of entries in a column which begin with 5 digits and a space with PostgreSQL?PostgreSQL 如何选择以 5 位开头和空格开头的列中的条目总数?
【发布时间】:2021-02-11 00:41:08
【问题描述】:

PostgreSQL 如何获取以 5 位开头和空格开头的列中的条目总数?

【问题讨论】:

    标签: sql string postgresql count where-clause


    【解决方案1】:

    你想要一个正则表达式匹配吗?

    select count(*) from mytable where col ~ '^\d{5}\s'
    

    col 是您要过滤的列的名称。正则表达式细分如下:

    ^        beginning of the string
    \d{5}    five digits
    \s       one space
    

    【讨论】:

      猜你喜欢
      • 2012-02-26
      • 2021-12-26
      • 1970-01-01
      • 1970-01-01
      • 2017-04-03
      • 1970-01-01
      • 2021-08-08
      • 2011-05-29
      • 1970-01-01
      相关资源
      最近更新 更多