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

MySQLMySQLi Database

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)
raja
Published on 20-Feb-2018 15:47:31
Advertisements