![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
#1
IP: 204.45.15.210
|
|||
|
|||
|
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?'. |
|
#2
IP: 204.45.15.210
|
|||
|
|||
|
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. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Find and Replace Text in MySQL Database using SQL | topvip | MySQL | 0 | 2012-07-10 08:12 AM |
| htaccess 301 redirect tutorial | yahoo | 服务器环境搭建 | 0 | 2009-09-06 12:45 AM |