
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can MySQL REPLACE() function be used with WHERE clause?
As we know that WHERE clause is used to put condition/s in MySQL query and MySQL returns result set based on those conditions. Similarly when we use REPLACE() function with WHERE clause, the result set will depend upon the conditions provided. Following is an example by using data from the ‘Student’ table in which REPLACE() function replaces the records of a column ‘Name’ in which the value of column ‘Subject’ is ‘Computers’.
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)
- Related Articles
- How can CONCAT() function be used with MySQL WHERE clause?
- How can CONCAT_WS() function be used with MySQL WHERE clause?
- How LOCATE() function can be used with MySQL WHERE clause?
- How MySQL LTRIM() and RTRIM()functions can be used with WHERE clause?
- How Groups function can be used in MySQL SELECT clause?
- How can we use ASCII() function with MySQL WHERE clause?
- How can we use CHAR_LENGTH() function with MySQL WHERE clause?
- How can we use BIN() function with MySQL WHERE clause?
- How can we use FIND_IN_SET() function with MySQL WHERE clause?
- How can we use MySQL INSTR() function with WHERE clause?
- How can I use SPACE() function with MySQL WHERE clause?
- How can REPLACE() be used with UPDATE clause to make permanent changes to a table?
- How Can we use MySQL DISTINCT clause with WHERE and LIMIT clause?
- How can we use MySQL REVERSE() function on column’s data along with WHERE clause?
- How can we use two columns with MySQL WHERE clause?

Advertisements