SQL to remove partial text from value

mysql, sql

Solution

The `REPLACE` feature of MySQL, SQL Server, and PostGres will remove all occurrences of `WEB` with a blank.

Selecting

SELECT REPLACE(Version, 'WEB ', '') FROM MyTable

Updating

UPDATE MyTable SET Version = REPLACE(Version, 'WEB ', '') 

or

UPDATE MyTable SET Version = REPLACE(Version, 'WEB ', '') WHERE Version LIKE '%WEB %'

Reference

- REPLACE - SQL Server

- REPLACE - MySQL

- REPLACE - PostGres

- I included multiple DB Servers in the answer as well as selecting and updating due several edits to the question

Problem

How would I write the SQL to remove some text from the value of records if it exists. ``` Version Column data ------------------ WEB 1.0.1 WEB 1.0.1 1.0.2 1.0.2 ``` I would like to update all records that contain "WEB " and remove that text but leave the rest, "1.0.1". So far I have `Select * from table`. Database is MySQL 5.5.25

Original source

Related problems