mysql - Remove string value after HTML delimiter from database? -
i'm migrating website different platform. inside database, have column named excerpt supposed contain intro text blog posts. after migrating database, i've come find excerpt column , content column duplicates of each other identical values. basic schema looks follows:
-------------------------------------------------------------------------- id | title | excerpt | content | -------------------------------------------------------------------------- 1 | post. |<p>text want.</p><p>text don't want.</p> |<p>text..| 2 | post. |<p>text want.</p><p>text don't want.</p> |<p>text..| 3 | next post. |<p>text want.</p><p>text don't want.</p> |<p>text..| 4 | post? |<p>text want.</p><p>text don't want.</p> |<p>text..| 5 | post? |<p>text want.</p><p>text don't want.</p> |<p>text..| -------------------------------------------------------------------------- what i'd know is, in excerpt column, how can remove after first </p> occurrence? i've been searching solution on last few days , thing i've come across regexp in sql i'm still rather new writing query commands.
any appreciated. thanks, everyone!
try this:
select excerpt, substring(excerpt, 0, locate('</p>', excerpt) + char_length('</p>')) your_table edit:
select excerpt, substring_index(excerpt, '</p>', 1) your_table
Comments
Post a Comment