How to Find and Replace Text in MySQL Database using SQL כיצד לחפש ולהחליף טקסט ב-MySQL מסד נתונים באמצעות SQL
MySQL database has a handy and simple string function REPLACE() that allows table data with the matching string (from_string) to be replaced by new string (to_string). מסד הנתונים MySQL יש תפקיד שימושי ופשוט מחרוזת REPLACE () המאפשר הנתונים בטבלה עם החוט תואמים (from_string) להיות מוחלף על ידי מחרוזת חדשה (to_string). This is useful if there is need to search and replace a text string which affects many records or rows, such as change of company name, postcode, URL or spelling mistake. אפשרות זו שימושית אם יש צורך לבצע חיפוש והחלפה של מחרוזת טקסט אשר משפיע רבות רשומות או שורות, כגון שינוי שם החברה, מיקוד, כתובת או טעות כתיב.
The syntax of REPLACE is REPLACE(text_string, from_string, to_string) התחביר של REPLACE הוא להחליף (text_string, from_string, to_string)
MySQL reference התייחסות MySQL describes REPLACE as function that returns the string text_string with all occurrences of the string from_string replaced by the string to_string, where matching is case-sensitive when searching for from_string. מתאר REPLACE כמו לפונקציה המחזירה את text_string מחרוזת עם כל המופעים של המחרוזת from_string הוחלף to_string את המחרוזת, איפה ההתאמה הוא תלוי רישיות כאשר מחפשים from_string. text_string can be retrieved from the a field in the database table too. text_string ניתן לאחזר מהשדה בטבלה מסד נתונים מדי. Most SQL command can be REPLACE() function, especially SELECT and UPDATE manipulation statement. רוב פקודת SQL ניתן REPLACE () function, במיוחד SELECT ולעדכן הצהרה מניפולציה.
For example: לדוגמה:
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string'); עדכון table_name להגדיר field_name = להחליף (field_name, "למצוא את המחרוזת ',' מצא מחליף מחרוזת במחרוזת זה ');
update client_table set company_name = replace(company_name, 'Old Company', 'New Company') עדכון company_name להגדיר client_table = להחליף (company_name, 'החברה הישנה', 'החברה החדשה')
The above statement will replace all instances of 'Old Company' to 'New Company' in the field of company_name of client_table table. ההצהרה לעיל יחליף את כל המופעים של 'החברה הישנה' ל 'חברה חדשה' בתחום company_name של שולחן client_table.
Another example: דוגמה נוספת:
SELECT REPLACE('www.mysql.com', 'w', 'Ww'); SELECT REPLACE ( 'www.mysql.com', 'W', 'WW');
Above statement will return 'WwWwWw.mysql.com' as result. מעל הצהרה יחזיר 'WwWwWw.mysql.com' כתוצאה.
IMPORTANT : The page is machine translated and provided "as is" without warranty. חשוב: הדף מכונת תירגם מתפרסם "כמות שהוא" ללא אחריות. Machine translation may be difficult to understand. תרגום מכונה יכול להיות קשה להבין. Please refer to נא עיין original English article המאמר המקורי באנגלית whenever possible. בכל הזדמנות אפשרית.
Related Articles מאמרים קשורים
- Remove or Trim First or Last Few Characters in MySQL Database with SQL להסיר או חתוך ראשית או דמויות האחרונים MySQL Database עם SQL
- Check and Optimize MySQL Database Automatically with Crontab/Cron בדוק ייעל MySQL Database אוטומטית עם crontab / Cron
- MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Error 1170 (42000): Blob / Text טור בשימוש קי מפרט ללא אורך מפתח
- MySQL Database Performance Tuning Best Practices Video Tutorial MySQL Database Performance Tuning Best Practices Video Tutorial
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database הפעל רישום של שאילתות איטי (Slow Query Log) ב-MySQL Database
- Change and Reset MySQL root Password שינוי סיסמה איפוס שורש MySQL
- Replace Notepad with Another Text Editor (eg. Notepad2 and Notepad++) in Vista להחליף את פנקס הרשימות עם עוד עורך טקסט (למשל Notepad2 ו 'פנקס רשימות + +) ב-Vista
- Download File Content Replacer to Search and Replace Text in Multiple Files הורדת קובץ תוכן Replacer כדי חיפוש ולהחליף טקסט מרובות קבצים
- Using PHP-MySQL Persistent Connections to Run WordPress Blog שימוש ב-MySQL PHP Persistent Connections כדי הפעלה בלוג WordPress
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial כיצד גיבוי ושחזור (ייצוא וייבוא) MySQL Databases Tutorial










































September 30th, 2009 15:26 30 ספטמבר 2009 15:26
Wanted to use REPLACE command to use for a column of a table…and this helped me…thanks רצה להשתמש בפקודה REPLACE להשתמש עבור עמודה של טבלה ... וזה עזר לי ... תודה