cnt
is a text column like this:
lorem,ipsum,sky,dolor
lorem,sky,ipsum
lorem,ipsum,dolor,sky
I want to remove sky
from entire column
$sq = "update table set cnt = replace(cnt, :a, :b)";
$st = $db->prepare($sq);
$st->execute([
":a" => 'sky'
":b" => ''
]);
Problem
sky
sometimes has a commma - it should be removed also
and sometimes is without comma (at the end of string)
How to remove sky
with and without comma?
My Answer:
"UPDATE table_name SET column_name = REPLACE(column_name, 'sky', '')"
Rate this post
5 of 5 based on 5291 votesComments