Search and replace within a field with regex in MySQL


/ Published in: MySQL

After a problem with row break in a text field I found this way of searching within a where clause in an SQL query. Can be used for selection or update / replace purposes of course.


Copy this code and paste it in your HTML
  1. SELECT * FROM 'table' WHERE `name` REGEXP '\r'
  2.  
  3. UPDATE 'table' SET 'field' = replace(field,"findvalue", "reaplcevalue") WHERE REGEXP 'regexp search expression'

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.