Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

333
Visualizações
sql query to replace backslashes '\\' with '\/'

I know very little about sql queries but I need a query to replace '\\' with '\/'

I have a Wordpress database where there are characters in a long text string that look like this in phpMyAdmin Browse.

'\\uploads\\photos\\'

It needs to be '\/uploads/photos\/'. I want a query to find '\\uploads\\photos\\' so I can make sure the query is working.

I also want another query to permanently replace '\\uploads\\photos\\' with '\/uploads\/photos\/'.

The below query that finds photos returns results, but that's as far as I got.

SELECT * 
FROM `mytable`
WHERE `mycolumn` LIKE '%photos%'

Thank you forpas for the excellent solution!

For future readers:
When I migrated my wordpress database from local online, all in one migration plugin missed the paths in wonderplugin gallery that I am using. Thus my requirement for the query.

This double backslashed \ text was in a long string and I was concerned that there were more double backslashes that could get changed. So adding on to the solution provided by forpas, I more accuratly targeted the path text. mytable was actually named wp_nonxenon_wonderplugin_gridgallery, and mycolumn was named data. This is the resultant query that will save me much work in the future.

UPDATE wp_nonxenon_wonderplugin_gridgallery SET data = REPLACE(data, 'wp-content\\uploads\\photos\\', 'wp-content\/uploads\/photos\/') WHERE data LIKE '%photos%';

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You must escape each backslash with a double backslash:

SELECT REPLACE(mycolumn, '\\\\', '\\/') 
FROM mytable
WHERE mycolumn LIKE '%photos%';

Or you can update the table:

UPDATE mytable
SET mycolumn = REPLACE(mycolumn, '\\\\', '\\/')
WHERE mycolumn LIKE '%photos%';

and the column will contain the values as you want them.

See the demo.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda