Home » » Using MySql replace function

Using MySql replace function

Written By Unknown on Selasa, 14 Januari 2014 | 09.22

MySql has a very useful function replace() which allows you to replace substring or characters. It is really useful while working with huge database table where you want to update certain values with another value. Its syntax is quite simple.


REPLACE ( field_name, 'find_string', 'replacement_string' );

To update some values in database table use query as follows using replace function.


UPDATE tutorials SET topic = REPLACE (topic, 'Php', 'Php MySql');

You can also run a select query using this function if you don't want to update table but want to fetch data as replaced. This will only output replaced values and there will be no changes in database.


SELECT REPLACE (topic, 'Php', 'Php MySql') as new_topic
FROM tutorials
WHERE topic = 'Php';

Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger