Skip to content
Advertisement

How to omit html tags in a mysql table attribute while doing a select

I have a table where each row consist of an attribute which consist of html data with like this.

I need to omit the html tags and extract only the data inside the tags using sql query. Any idea on how to achieve this?. I tried out different regex but they didnt work.

Advertisement

Answer

There are 2 solutions based on mysql version.

If you are using MySQL 8.0 then you can use REGEXP_REPLACE() directly inside the select statement.

If you are using MySQL 5.7 then you have to create a user define function in database to strip html tags.

For example

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement