0

I'm trying to update a column in MySQL which > 100k entries. My column has value like

<div class="class1">
<div class="class2">
<span>
<a title="Search for Product" 
 href="${firstProductLink}/product/product.html">Search for product
</a>
</span>
<span>
<a title="Search for Product" 
href="${firstProductLink}/sample/sample.html">Search for sample
</a>
</span>
<span>
<a title="Search for Product" 
href="${secondProductLink}/product/product.html">Search for product
</a>
</span>
</div>
</div>

in this column I need to replace anchor tag has firstProductLink to empty, like

<div class="class1">
<div class="class2">
<span>
</span>
<span>
</span>
<span>
<a title="Search for Product" 
href="${secondProductLink}/product/product.html">Search for product
</a>
</span>
</div>
</div>

I tried to find the index of href="${firstProductLink} by using LOCATE mysql method. Then I'm unable to find index of left and right anchor tag(). So that I can use replace mysql method.

James Z
  • 12,209
  • 10
  • 24
  • 44
Ijaz
  • 421
  • 1
  • 6
  • 23
  • 1
    The easiest way to do this is by replacing a regular expression. See https://stackoverflow.com/questions/986826/how-to-do-a-regular-expression-replace-in-mysql – Barmar Apr 24 '19 at 10:17
  • 1
    In a normal query it's not possible to do an unbounded number of replacements. You would need to use a stored procedure to loop over all the matches. – Barmar Apr 24 '19 at 10:18

0 Answers0