SelectName,REPLACE(Name,'G','S')fromstudentWhereSubject=&a"/> SelectName,REPLACE(Name,'G','S')fromstudentWhereSubject=&a">

Home  >  Article  >  Database  >  How is the MySQL REPLACE() function used with the WHERE clause?

How is the MySQL REPLACE() function used with the WHERE clause?

王林
王林forward
2023-08-31 17:25:06720browse

MySQL REPLACE() 函数如何与 WHERE 子句一起使用?

We know that the WHERE clause is used to add conditions in a MySQL query, and MySQL returns a result set based on these conditions. Similarly, when we use REPLACE() function with WHERE clause, the result set will depend on the conditions provided. The following is an example using data from the "Students" table, where the REPLACE() function replaces records in the "Name" column where the "Subject" column has the value "Computer".

Example

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

The above is the detailed content of How is the MySQL REPLACE() function used with the WHERE clause?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete