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

MySQLMySQLi Database

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’.

raja
Published on 20-Feb-2018 21:50:32
Advertisements