Reputation: 883
UPDATE name SET name = REPLACE(student_name, 'a', ''');
By using the code above I want to update a to become '. How is that possible?
Upvotes: 1
Views: 186
Reputation: 1635
There are several ways to include quote characters within a string:
“'” inside a string quoted with “'” may be written as “''”.
“"” inside a string quoted with “"” may be written as “""”.
Precede the quote character by an escape character (“\”).
“'” inside a string quoted with “"” needs no special treatment and need not be doubled or escaped. In the same way, “"” inside a string quoted with “'” needs no special treatment.
Upvotes: 0
Reputation: 62536
Escape the '
by using \'
:
UPDATE name SET name = REPLACE(student_name, 'a', '\'');
Or use double-quote:
UPDATE name SET name = REPLACE(student_name, 'a', "'");
Upvotes: 3