How to Find and Replace Text in MySQL Database using SQL Cara Cari dan Ganti Teks di MySQL Database menggunakan 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 database yang berguna dan sederhana fungsi string REPLACE () yang memungkinkan data tabel dengan pencocokan string (from_string) yang akan diganti dengan string baru (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. Ini berguna jika ada kebutuhan untuk mencari dan mengganti teks string yang berdampak pada banyak catatan atau baris, seperti perubahan nama perusahaan, kode pos, URL atau kesalahan ejaan.
The syntax of REPLACE is REPLACE(text_string, from_string, to_string) Sintaks REPLACE adalah REPLACE (text_string, from_string, to_string)
MySQL reference MySQL referensi 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. menggambarkan REPLACE sebagai fungsi yang mengembalikan string text_string dengan semua kejadian from_string tali digantikan oleh string to_string, dimana pencocokan kasus-sensitif ketika mencari from_string. text_string can be retrieved from the a field in the database table too. text_string dapat diambil dari lapangan di tabel database juga. Most SQL command can be REPLACE() function, especially SELECT and UPDATE manipulation statement. Sebagian besar perintah SQL dapat REPLACE () fungsi, terutama SELECT dan UPDATE pernyataan manipulasi.
For example: Contoh:
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string'); update TABLE_NAME set FIELD_NAME = menggantikan (FIELD_NAME, 'menemukan string ini', 'menggantikan ditemukan string dengan string ini');
update client_table set company_name = replace(company_name, 'Old Company', 'New Company') update client_table set company_name = menggantikan (company_name, 'Old Company', 'New Company')
The above statement will replace all instances of 'Old Company' to 'New Company' in the field of company_name of client_table table. Pernyataan di atas akan mengganti semua contoh 'Old Company' untuk 'New Company' dalam bidang company_name dari client_table meja.
Another example: Contoh lain:
SELECT REPLACE('www.mysql.com', 'w', 'Ww'); SELECT REPLACE ( 'www.mysql.com', 'w', 'Ww');
Above statement will return 'WwWwWw.mysql.com' as result. Pernyataan di atas akan kembali 'WwWwWw.mysql.com' sebagai hasilnya.
IMPORTANT : The page is machine translated and provided "as is" without warranty. PENTING: Halaman ini adalah mesin diterjemahkan dan diberikan "sebagaimana adanya" tanpa jaminan. Machine translation may be difficult to understand. Terjemahan mesin mungkin sulit untuk mengerti. Please refer to Silakan merujuk ke original English article artikel asli bahasa Inggris whenever possible. bila memungkinkan.
Related Articles Artikel Terkait
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Hapus atau Trim Pertama atau Sedikit Terakhir Pop di MySQL Database dengan SQL
- Check and Optimize MySQL Database Automatically with Crontab/Cron Periksa dan Optimalkan MySQL Database Secara Otomatis dengan Crontab / Cron
- MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Error 1170 (42000): BLOB / TEXT Kolom Digunakan di Key Spesifikasi Tanpa Key Length
- 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 Aktifkan Logging Slow Query (Query Lambat log) di MySQL Database
- Change and Reset MySQL root Password Perubahan dan Reset MySQL root Password
- Replace Notepad with Another Text Editor (eg. Notepad2 and Notepad++) in Vista Ganti Notepad dengan Text Editor lain (mis. Notepad2 dan Notepad + +) di Vista
- Download File Content Replacer to Search and Replace Text in Multiple Files Download File Konten Replacer untuk Cari dan Ganti Teks di Multiple Files
- Using PHP-MySQL Persistent Connections to Run WordPress Blog Menggunakan PHP-MySQL Koneksi Persistent untuk Jalankan Wordpress Blog
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Cara Backup dan Restore (Ekspor dan Impor) Tutorial MySQL Databases










































October 20th, 2009 20:28 20 Oktober 2009 20:28
Doesn't work at all for replacing web addresses within a database. Tidak bekerja sama sekali untuk mengganti alamat web dalam database.
September 30th, 2009 15:26 30 September 2009 15:26
Wanted to use REPLACE command to use for a column of a table…and this helped me…thanks Ingin menggunakan perintah REPLACE digunakan untuk kolom tabel ... dan ini membantu saya ... terima kasih