0

so i´ve change my mind....

i´ve enter around 1200 records into a text type field... like so:

this is <span class="italic">the</span> flower<br />
that speaks the mind<br />
bla bla bla<br />

If you notice, i've inserted a class named italic... well that is my mistake... I need to loop all of the 1200 records and replace the class italic with espWord

How do i achieve that ?

SELECT lyrics.lyrics_id, lyrics.lyrics
FROM lyrics
WHERE ?????

replace italic with espWord

2 Answers 2

1

UPDATE lyrics set lyrics.lyrics = replace(lyrics.lyrics, 'italic', 'espWord');

I would never personally have a table name with a field of the same name; to great a potential for confusion.

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

3 Comments

Note that this will replace all "italic" found in the whole text.
lets hope not to may people sing of font styles :-)
wow! that was fast... tried it and it works... 1200 records updated in 0.016 seconds !!!
0

I'm not well versed enough with MySql to say if there's a complete MySql solution, but You could try selecting the data like

SELECT SELECT lyrics.lyrics_id, lyrics.lyrics
FROM lyrics
WHERE `field` LIKE '%<span class=\"italics\">%'

Then use a program like preg_replace or sed to replace the value and update the field. I haven't used both in long enough that I can't think of the expression off the top of my head.

Hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.