Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

212
Vistas
Update value of table row which could contain href without target

Imagine you have table called Information which could have two columns id and text_with_hrefs_with_or_without_target_blank, which we want to update

So for example one of many rows could have stored this value in the column text_with_href....

first href with target blank before

<a target="_blank" href="http://link1.com">Link1</a>

maybe another text and link with target

<a href="http://www.link2.com">Link2</a>

and last href link with target blank after href

<a href="http://www.link3.com" target="_blank">Link3</a>

I would like to update all similiar rows in table Information to add target=_blank to hrefs in those parts of rows which havent one

so the result for this row I mentioned would look like

first href with target blank before

<a target="_blank" href="http://link1.com">Link1</a>

maybe another text and link with target

<a href="http://www.link2.com" target="_blank">Link2</a>

and last href link with target blank after href

<a href="http://www.link3.com" target="_blank">Link3</a>
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

As pointed out in comments you better off doing it in your client/presentation code.

Now if you absolutely need to do this in the database, especially if it's just a one time thing, and assuming that you have one and only one link <a></a> per row you can do something as simple as this

UPDATE information
   SET text_with_hrefs_with_or_without_target_blank = 
           replace(text_with_hrefs_with_or_without_target_blank, '<a ', '<a target="_blank" ')
 WHERE text_with_hrefs_with_or_without_target_blank NOT LIKE '%target="_blank"%'

SQLFiddle

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda