Use REPLACE Function with Column Data in 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: 2020-06-20T10:52:56+05:30

188 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements