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)

Updated on: 20-Jun-2020

116 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements