Computer >> Computer tutorials >  >> Programming >> MySQL

How to use REPLACE() function with column’s data of MySQL table?


For using it with column’s data we need to provide column name as the argument of REPLACE() function. It can be demonstrated by using ‘Student’ table data as follows −

Example

mysql> Select Id, Name, Subject, REPLACE(Subject, 's', ' Science') from Student WHERE Subject = 'Computers';
+------+--------+-----------+-----------------------------------+
| Id   | Name   | Subject   | REPLACE(Subject, 's', ' Science') |
+------+--------+-----------+-----------------------------------+
| 1    | Gaurav | Computers | Computer Science                  |
| 20   | Gaurav | Computers | Computer Science                  |
+------+--------+-----------+-----------------------------------+
2 rows in set (0.00 sec)