我有一个字段urn_sem.studentid
,我想替换几个字符;例如:
ABC/2011/BCOMH_NC/I/12
→ABC/2011/BCOMH/I/12
ABC/2011/BCOMH_NC/I/24
→ABC/2011/BCOMH/I/24
我尝试过这个问题:
SELECT REPLACE(studentid, 'KNC/2011/BCOMH_NC/', ' KNC/2011/BCOMH/')
FROM urn_sem
但它没有显示新值。
答案 0 :(得分:1)
你想要这个:
update urn_sem
set studentid = REPLACE(studentid, 'KNC/2011/BCOMH_NC/', ' KNC/2011/BCOMH/')
where studentid like '%KNC/2011/BCOMH_NC/%'
WHERE
子句是可选的。它确保替换仅适用于更改的行。
答案 1 :(得分:0)
此示例查询不起作用? SELECT REPLACE(studentid,'_','')FROM urn_sem