Johnson John
Johnson John

Reputation: 3

MySQL Replace function

I am trying to display all the people who name Jason, and replace Jason to Jill.

However, I tried the following SQL statement is not working

SELECT * FROM DigitalTV WHERE REPLACE('Jason', 'ason', 'ill');

Upvotes: 0

Views: 29

Answers (1)

vahdet
vahdet

Reputation: 6729

Assuming that the column you want to replace names is called NAME, you can use a query like:

SELECT 
  *,
  REPLACE(NAME, 'ason', 'ill') As CHANGED_NAME
FROM DigitalTV 
WHERE NAME='Jason';`

This will bring an extra column with the name CHANGED_NAME. If you do not want it, use each and every column name in the selector but NAME. It should be modified as REPLACE(NAME, 'ason', 'ill')

Upvotes: 1

Related Questions