Forum Moderators: open
I have a table T with 3 fields A, B and C that contain text.
Sometime the text contains quotation and sometimes the quotation is inserted in tag <i> </i>. I'd like to write a query that update any field in which '<i>"*"</i>' occurs into '"*"'.
Is it possible to do that with mySql? Or should I write a PHP program? What is the fastes/most elegant way?
Thank you a lot for your attention!
Now I got the main idea. Thanks.
I have a field in which <i> </i> can be contained.
But I'd like that the text of the field is the 1st argument of replace.
Something like:
update myTable = set myField = REPLACE(SELECT note FROM canzoni,'<i>','');
Of course that doens't work.
With PHP I could do:
$ptr = mysql_query("SELECT myField, id FROM myTable");
// ...inside the reading loop with $myArr the array that stores DB data
mysql_query("UPDATE myTable = set myField = REPLACE($myArr[0], '<i>', '') WHERE id=$myArr[1]");
mysql_query("UPDATE myTable = set myField = REPLACE($myArr[0], '</i>', '') WHERE id=$myArr[1]");
But I'd prefer to write a single query once and for all. Is that possible?
Thanks!