23

I want a query in SQL that change all 'a' in string to 'b' in first_name column in name table. Here is my columns name: first_name | list_name

0

2 Answers 2

52

use REPLACE()

UPDATE tableName
SET first_name = REPLACE(first_name, 'a', 'b')

but remember that REPLACE() is case sensitive.

Sign up to request clarification or add additional context in comments.

2 Comments

is there another function that is not case sensitive ?, or a parameter we can pass to REPLACE ?
7

You can try this:

UPDATE name SET first_name = REPLACE (first_name, 'a', 'b') WHERE blabla LIKE '%blabla%';
OR
UPDATE name SET first_name = REPLACE (first_name, 'a', 'b') WHERE blabla = 'blabla';

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.