The Kingdom Tech The Kingdom Tech - 5 months ago 9
SQL Question

Change one character in PostgreSQL column string

I have a hundreds of entries in a description column that look like the following:

CAP 0.001UF ±10% 50V X7R 0402


I need to change it to:

CAP 0.001UF +/-10% 50V X7R 040


How can I search through the records and change all instances of
±
to
+/-
?

Answer

How about using replace() and like?

update t
    set description = replace(description, '±', '+/-')
    where description like '%±%';