Reputation: 576
I have a column in database which has HTML format data.
<div id="subtitle"><h2>Quisque cursus metus vitae, sem massa mattis sem.</h2></div>
I don't have access to how the database gets updated, is there a way I can strip the enclosing div
via SQL? I would like to remove the enclosing <div id="subtitle">
tag to just have this instead in the column:
<h2>Quisque cursus metus vitae, sem massa mattis sem.</h2>
Upvotes: 0
Views: 43
Reputation: 24549
Using SQL for this sort of thing is not really ideal. You would probably be better off doing it with a programming language. That being said, under the assumption that the enclosing div always looks like <div id="subtitle">
and </div>
, you could probably do something like this:
SELECT REPLACE(REPLACE(myTable.myColumn, '<div id="subtitle">', ''),'</div>','');
I've not tested that. I actually don't even know if it is possible to nest the REPLACE function like that, but give it a try and see if it works for you.
Upvotes: 1