从MySQL数据库列中的数据条带化HTML

Probably based on this question: Best way to strip html tags from a string in sql server?

Think of me as a noob. I have a field with data in it. I need to strip html from this column and I'm aware that there is a PHP function that does this. What do I do to do this in my SQL database?

What do I enter for the query? Select my column (the field I call it) from the table...and then?

Using strip_tag() function

// assuming that you're using MySQL
$result = mysqli_query("SELECT column FROM table");
while ($row = mysqli_fetch_array($result)) {
  echo strip_tags($row['column']) . '<br />';
}

or using preg_replace() function and this simple regular expression <[^>]*>

echo preg_replace('/<[^>]*>/', '', $row['column']);

Working PHP demo

Recomended method: strip_tags() function in this case. It takes two arguments; the first one is the text itself and the second one contains allowed tags; so, for instance, if you want to keep <a> and clean everything else you simply use it like this:

strip_tags($text, '<a>');

i am not a MS SQL user, but as i have seen the link you posted. its all explained there. All you need is to create a function by copy pasting that code.

//Function From the Link Given in Question

CREATE FUNCTION [dbo].[udf_StripHTML]
(@HTMLText VARCHAR(MAX))
RETURNS VARCHAR(MAX)
AS
BEGIN
DECLARE @Start INT
DECLARE @End INT
DECLARE @Length INT
SET @Start = CHARINDEX('<',@HTMLText)
SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))
SET @Length = (@End - @Start) + 1
WHILE @Start > 0
AND @End > 0
AND @Length > 0
BEGIN
SET @HTMLText = STUFF(@HTMLText,@Start,@Length,'')
SET @Start = CHARINDEX('<',@HTMLText)
SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))
SET @Length = (@End - @Start) + 1
END
RETURN LTRIM(RTRIM(@HTMLText))
END
GO

and i guess you can use query like this using the function above.

select * from table where dbo.udf_StripHTML(Content1) like ‘%Hello%’

im not sure about the above query, but i think it would be something like that. However the above function defined, just try to use in query, may be it solves your problem.