How can I fetch the value of REPLACE() function in the column name of our choice?


For fetching the values of REPLACE() function in our choice column name, we need to use the keyword ‘AS’ with REPLACE() function.

Example

mysql> Select Name, REPLACE(Name, 'G','S') AS Name_Changed from student Where Subject = 'Computers';
+--------+--------------+
| Name   | Name_Changed |
+--------+--------------+
| Gaurav | Saurav       |
| Gaurav | Saurav       |
+--------+--------------+
2 rows in set (0.00 sec)

The query above will give the result set of REPLACE() function in column name of our choice ‘Name_Changed’ which is given after keyword ‘AS’.

Updated on: 30-Jul-2019

61 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements