LaserBeak LaserBeak - 1 year ago 57
SQL Question

Find if a string from one field is contained in another field on the same row and delete it if so

Say I have the following fields in each row

Make Model
Toyota Toyota Camry

I need a query that will check if the string in Make is also contained in Model and delete the portion of Model value that matches.

Answer Source

Perhaps this is what you're looking for with replace:

update yourtable 
set model = replace(model, make, '');