![]() |
Mysql search and replace some text in a field
What Mysql query will do a text search and replace in one particular field in a table?
ie search for 'children eyeglasses' and replace with 'kids glasses' so a record with a field with the value : 'How to buy children eyeglasses online?' becomes: 'How to buy kids glasses online?'. |
Change table_name and field to match your table name and field in question:
Code:
UPDATE table_name SET field = REPLACE(field, 'children eyeglasses', 'kids glasses') WHERE INSTR(field, 'children eyeglasses') > 0;INSTR (ori_str, sub_str): ori_str The string to be searched. sub_str The string to be searched for within the ori_str MySQL INSTR() takes a string and a substring of it as arguments, and returns an integer which indicates the position of the first occurrence of the substring within the string. |
| All times are GMT +8. The time now is 01:19 AM. |
Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.