Reputation: 11
I want to write a query to remove '' strings from an entry up until '>' characters.
Say I have:
<a href='somesite'>Text Link</a>
The result should be:
Text Link</a>
Upvotes: 1
Views: 184
Reputation: 10074
As Christopher and Dor noted, this is almost certainly better done in your code. Still, just for fun, here is how you might do it in MySQL.
SELECT SUBSTRING(`your_column`, LOCATE('>', `your_column`,
LOCATE('<', `your_column`)) + 1)
FROM `your_table`;
Upvotes: 1
Reputation: 37364
You can try this:
SET @tmp = "<a href='somesite'>Text Link</a>";
SELECT RIGHT(@tmp,LENGTH(@tmp)-LOCATE('>',@tmp));
Note: LOCATE
finds the first occurrence of substring; that may or may not what you want.
Upvotes: 1