【问题标题】:oracle 10g using update and concatoracle 10g 使用更新和连接
【发布时间】:2019-03-13 11:22:11
【问题描述】:

我的表结构是这样的。

gno  gdate             DCNo    DCDATE 
g/1  11/12/2018        cnt/1   12/12/2018
g/2  20/12/2018        cnt/2   13/12/2018
g/3  11/12/2018         3      11/12/2018
g/4  10/12/2018         4      10/12/2018 

我想用cnt/no 更新dcno 中的所有列。这里第 3 行和第 4 行必须更新为 cnt/3 和 cnt/4

【问题讨论】:

  • Oracle REGEXP_LIKE 是您的朋友。在互联网上搜索它。

标签: sql oracle concat


【解决方案1】:

试试这个

update tablename set dcno='cnt/'||dcno
where dcnot not like 'cnt/%'

【讨论】:

    【解决方案2】:

    这是你想要的吗?

    update t
        set DCNO = 'cnt/' || DCNO
        where DCNO not like 'cnt/%';
    

    【讨论】:

      【解决方案3】:

      用例

      update table
      set DCNo= case when DCNo in ('3','4')then 'cnt/'||DCNO end
      

      【讨论】:

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