Using MySql replace function
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.
To update some values in database table use query as follows using replace function.
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.
REPLACE ( field_name, 'find_string', 'replacement_string' );
UPDATE tutorials SET topic = REPLACE (topic, 'Php', 'Php MySql');
SELECT REPLACE (topic, 'Php', 'Php MySql') as new_topic FROM tutorials WHERE topic = 'Php';
Using MySql replace function Reviewed by Altaf Hussain on 10:52 PM Rating: