如何只编辑列中的某些字符串?
How to only edit certain strings in column?
我在 sql table 中有 table,看起来像这样:
column
1
2
welcome from henry
welcome from beth
welcome
3
4
如何仅将 'Welcome from' 的值编辑为仅 'Welcome'?
新专栏:
1
2
welcome
welcome
welcome
3
4
我无法编辑 table,必须在 select 语句中执行此操作。
您可以使用:
UPDATE tab
SET col = 'welcome'
WHERE col LIKE 'welcome %'
编辑:
Unfortunately I cant update any tables, I can only do it select statements
SELECT CASE WHEN col LIKE 'welcome %' THEN 'welcome' ELSE col END AS col
FROM tab
UPDATE table_name
SET column_name = 'VALUE YOU WANTS TO ADD IN PLACE OF OLD'
WHERE column_name LIKE 'old_value %;'
我在 sql table 中有 table,看起来像这样:
column
1
2
welcome from henry
welcome from beth
welcome
3
4
如何仅将 'Welcome from' 的值编辑为仅 'Welcome'?
新专栏:
1
2
welcome
welcome
welcome
3
4
我无法编辑 table,必须在 select 语句中执行此操作。
您可以使用:
UPDATE tab
SET col = 'welcome'
WHERE col LIKE 'welcome %'
编辑:
Unfortunately I cant update any tables, I can only do it select statements
SELECT CASE WHEN col LIKE 'welcome %' THEN 'welcome' ELSE col END AS col
FROM tab
UPDATE table_name
SET column_name = 'VALUE YOU WANTS TO ADD IN PLACE OF OLD'
WHERE column_name LIKE 'old_value %;'