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

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

王林
Release: 2023-08-31 17:25:06
forward
837 people have browsed it

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template