Fii
Fii

Reputation: 39

Removing a character (a specific slash) in every cell of a database field, using MySQL

I have a table, using MySql-PHPMyAdmin. Like how appears on the image.

enter image description here

My problem is there are two slashes after each http://www.statsoft.com. Though it's not really a problem when I run some queries on the link field, I can't help but notice these two slashes. I'd like to remove one of the slashes, in each cell, with one update function. How do I do that? I googled for addressing this problem, but I couldn't find a nice solution. Yet I don't really know how SQL queries deal with this.

I've tried:

UPDATE  `glossary`.`glossary`
  SET  `link` =  'http://www.statsoft.com//textbook/statistics-glossary/c/?button=0#Curse'
  WHERE  `glossary`.`link` =  'http://www.statsoft.com//%';

And of course it changed the value at every single row. I also tried this:

update glossary
set link= REPLACE(link,'/','')

And it removed all slashes. -_- What do I do? Thanks.

Upvotes: 0

Views: 105

Answers (1)

Mihai Matei
Mihai Matei

Reputation: 24276

UPDATE glossary
SET link=REPLACE(link,'.com//','.com/')

Upvotes: 3

Related Questions