1

I have a function called strip_tags defined in postgreSQL which strips out HTML tags in a given string.(I know trying to strip out html tags at db level is frowned upon, but i have to do this).

I want to extract some news from my db therefore I am executing a query:

SELECT description FROM news WHERE description ilike '%apple%'

Data in the description column is a mixture of html and text and i want to strip the html and then search if it matches '%apple%' or not! somewhat like:

SELECT description FROM news WHERE (select strip_tags(description)) ilike '%apple%'

Is this possible in postgreSQL? I tried executing this query but it dint work!

1 Answer 1

1

You can use the function in your WHERE condition.

SELECT description 
FROM news 
WHERE strip_tags(description) ilike '%apple%'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.