简体   繁体   English

如何将列中的所有字符串值替换为另一个值?

[英]How to replace all string values from a column to another value?

I want to replace all values from a column, like for example, to replace all values from lane column to 'All lanes' value.我想替换列中的所有值,例如,将lane列中的所有值替换为“所有车道”值。 I tried to use REPLACE function: REPLACE(lane, '%', 'All lanes') but it does not work that way though.我尝试使用 REPLACE function: REPLACE(lane, '%', 'All lanes')但它不起作用。 Any thoughts?有什么想法吗? Thanks in advance!提前致谢!

lane车道
WA-OR WA-OR
TX-NY德克萨斯-纽约
MA-NJ马-新泽西

Expected output:预期 output:

lane车道
All lanes所有车道
All lanes所有车道
All lanes所有车道

Just use update :只需使用update

update t
    set lane = 'All lanes';

Note this permanently affects all rows.请注意,这会永久影响所有行。 If you just want the result in a query:如果您只想查询结果:

select 'All lanes' as lane
from t;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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