Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

search and replace question

heidiland's profile image heidiland posted 2 years ago in General Permalink


i am new to heidisql and have a search and replace question. I have a database with multible fields. I need to replace the following thing

img src="//mydomain/track.php?track=L2FjdGlvbi5tZXRhZmZpbGlhdGlvbi&id=93820fddd4b8bd8511f7ca9" style="width: 1px; height: 1px"

The encoded numbers always are different. The rest is always the same. Does anybody know how I can remove this from the database via heidisql? Does anybody know if a regex like (...) Capture everything enclosed works via the search and replace dialog box?

kind regards


ansgar's profile image ansgar posted 2 years ago Permalink

REGEXP_REPLACE is what you want:

  somecol = REGEXP_REPLACE(
    '<img src\=\"\/\/mydomain\/track.php\?track\=([a-zA-Z0-9]+)\" [^>]*>',
    '<div>New contents with old track id: \\1</div>'
  somecol LIKE '%whatever%'

Not sure about the backslash escaping, I think there always need to be two (not one!) backslashes in front of a reserved character like double quote.

Please login to leave a reply, or register at first.