Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
Actualice el valor de la fila de la tabla que podría contener href sin objetivo

Imagine que tiene una tabla llamada Información que podría tener dos columnas id y text_with_hrefs_with_or_without_target_blank, que queremos actualizar

Entonces, por ejemplo, una de muchas filas podría haber almacenado este valor en la columna text_with_href....

primer href con destino en blanco antes

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

tal vez otro texto y enlace con destino

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

y último enlace href con destino en blanco después de href

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

Me gustaría actualizar todas las filas similares en la información de la tabla para agregar target=_blank a hrefs en aquellas partes de las filas que no tienen una

entonces el resultado de esta fila que mencioné se vería así

primer href con destino en blanco antes

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

tal vez otro texto y enlace con destino

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

y último enlace href con destino en blanco después de href

 <a href="http://www.link3.com" target="_blank">Link3</a>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Como se señaló en los comentarios, es mejor que lo haga en su código de cliente/presentación.

Ahora, si es absolutamente necesario hacer esto en la base de datos, especialmente si es solo una vez, y asumiendo que tiene un solo enlace <a></a> por fila, puede hacer algo tan simple como esto

 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"%'

violín SQL

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!