I have a quite large MySQL db table (posts) and in one field (post_text) there are a lot of old BB code that needs trimming.
This is one example of what i need to find: quote:1270ae936b
(after : characters varies, always 10)
And replace with: quote:
How do i do this in SQL command?
Thanks in advance! :)
Not tested but logically it should work for you. check more about specific range of characters at http://dev.mysql.com/doc/refman/5.7/en/pattern-matching.html
Test Query:
//run it before update query
SELECT post_text FROM posts WHERE post_text REGEXP 'quote:[a-zA-Z0-9]{10}';
Main Query:
UPDATE posts
SET post_text = 'quote:'
WHERE post_text REGEXP 'quote:[a-zA-Z0-9]{10}';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.