LaserBeak LaserBeak - 1 year ago 71
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, '');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download