【问题标题】:Remove all characters after a period in SQL在SQL中删除一段时间后的所有字符
【发布时间】:2016-04-25 19:46:40
【问题描述】:

我正在查询具有如下结果的表/列:

abc.1234  
abcdef.123  
ab.12345  

我这样查询:

Select
Program.fullname as "Full Name"

我只想返回abc, abcdef, ab。 无法弄清楚如何做到这一点(尽管我怀疑它应该很简单)

当我跑步时:

instr(Program.fullname) as "Full Name" ,它只返回期间的索引。我需要添加什么来获取句点之前的实际字符串?

【问题讨论】:

标签: sql


【解决方案1】:

对于 Mysql,这是可行的

Select
SUBSTRING_INDEX(Program.fullname, '.', 1)  as "Full Name"

【讨论】:

    【解决方案2】:

    substr(Program.fullname, 1, instr(Program.fullname,'.')-1) 作为“全名”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-09
      • 2011-10-10
      • 2020-10-03
      • 1970-01-01
      • 1970-01-01
      • 2018-05-31
      • 1970-01-01
      相关资源
      最近更新 更多