简体   繁体   中英

oracle 10g using update and concat

My table structure is this.

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 

I want to update all columns in dcno with cnt/no. here row 3 and 4 have to be updated to cnt/3 and cnt/4

Is this what you want?

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

Try this

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

use case

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM