I’m trying to run the following statement but it is not working as expected.
It is meant to take the subquery value and remove it from the comment field (replace with empty string).
I have checked that the sub query returns the right value that I expect but the replace function isn’t working as I would expect. Would anyone have any ideas?
Thank you in advance.
update contacts set comment =
replace(comment,
(select 'Specialty: ' + a.categoryname
from contacts c
join categories a
on c.categorycode = a.categorycode
where contacts.contactid = c.contactid)
, '')
this should do i guess
in sqlfiddle