There is some text column containing some value. E.g.
开发者_如何学JAVA<ul>
<li>bla bla bla bla bla bla bla bla.</li>
<li>bla bla bla bla bla bla bla bla.</li>
</ul>
or
<br />• text text text.
<br />• text text text.
<br />
How do I remove only the first <br/>
tag in each record that begins with it?
If you only want to remove the 1st <br />
if the record starts with <br />
:
UPDATE table
SET field = SUBSTRING(field, 7)
WHERE LEFT(field, 6) = '<br />'
You can just use the mysql trim function:
TRIM(LEADING '<br />' FROM column_name)
example:
SELECT TRIM(LEADING '<br />' FROM doyouknow) as doyouknow FROM actors;
This will remove the "<br />" from the start of doyouknow if it is there or do nothing. This will not change the data in your database like an update query.
SELECT
CASE WHEN doyouknow LIKE '<br />%' THEN SUBSTRING(doyouknow, 7) ELSE doyouknow END,
othercol1,
othercol
FROM..
If you need to update the data in the table, use this
UPDATE TBL
SET doyouknow =
CASE WHEN doyouknow LIKE '<br />%' THEN SUBSTRING(doyouknow, 7) ELSE doyouknow END,
精彩评论