我有一个表名tariff,但现在我想替换列中的值service_code
值是这样的:
D2P
D2D
D2D
D2P
D2D
Run Code Online (Sandbox Code Playgroud)
我想要实现的目标:
P2P
P2D
P2D
P2P
P2D
Run Code Online (Sandbox Code Playgroud)
只需将“D”更改为“P”作为第一个字符
使用以下查询:
UPDATE tariff SET service_code=CONCAT('P', SUBSTRING(service_code FROM 2))
where substring(service_code,1,1)='D';
Run Code Online (Sandbox Code Playgroud)
或者
UPDATE tariff SET service_code=CONCAT('P', SUBSTRING(service_code FROM 2))
where left(service_code,1)='D';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4010 次 |
| 最近记录: |