1

I have table in a sql table that looks like this:

column
1
2
welcome from henry
welcome from beth
welcome
3
4

How do I only edit the values that have 'Welcome from' to become only 'Welcome'?

New column:

1
2
welcome
welcome
welcome
3
4

I can not edit the table, have to do this in select statement.

RustyShackleford
  • 3,462
  • 9
  • 40
  • 81

2 Answers2

1

You could use:

UPDATE tab
SET col = 'welcome'
WHERE col LIKE 'welcome %'

EDIT:

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
Lukasz Szozda
  • 162,964
  • 23
  • 234
  • 275
0
UPDATE table_name 
SET column_name = 'VALUE YOU WANTS TO ADD IN PLACE OF OLD'
WHERE column_name LIKE 'old_value %;'
forpas
  • 160,666
  • 10
  • 38
  • 76
Creator
  • 303
  • 4
  • 23