If it is a fixed text snippet:
If it’s purely text replacement it’ll be the same problem as me I answered here.
Uses the function Replace
to replace that part of the content.
Would look like this:
UPDATE produtos
SET obs= REPLACE(obs, '<p><a target="_blank" href="/uploads/docs/58e7a4fd05ca6.pdf "><img alt="" style="width: 175px; height: 45px;" src="/uploads/imagens/59d292393a88f_900x.jpg" /></a></p>', '')
WHERE obs LIKE '%<p><a target="_blank" href="/uploads/docs/58e7a4fd05ca6.pdf "><img alt="" style="width: 175px; height: 45px;" src="/uploads/imagens/59d292393a88f_900x.jpg" /></a></p>%'
If the content of P be variable
You can use a combination of SUBSTRING
with INSTR
:
UPDATE produtos
SET obs = SUBSTRING(obs, 0, INSTR(obs,'<p>')) + SUBSTRING(obs, INSTR(obs,'</p>'))
WHERE obs IS NOT NULL AND
INSTR(obs, '<p>') >=0 AND
INSTR(obs, '</p>') >=0
The SUBSTRING
in syntax SUBSTRING( str, inicio, quantidade)
will return [quantidade
] characters from position [inicio
] string [str
]
Already in the syntax SUBSTRING( str, inicio )
, the function returns all characters of [str
] from the position [inicio
].
The function INSTR
- INSTR( str, strProcurada)
- a value greater than or equal to zero corresponding to the index of the initial position of the string str
where the text is found strProcurada
.
If there are several P nested in the column and you want to remove a specific
You can replace from regular expressions (REGEXP
). But to respond specifically, we would have to know the basic structure of the code you’re looking for.
I hope I’ve helped.
You want to be alone with the tags? Erase everything? It wasn’t clear to me
– rLinhares
I answered there, but reading the @rLinhares question really raised some doubts: the content within this P is variable in each record (i.e., reference different links and images)? In this column there is a chain of chained elements that include several P and you want to remove only the P more internal?
– Diego Rafael Souza