Using of Regexp_Replace in PostgreSQL Query

28 Views Asked by At

I have built a query for my customer support team, and one of the field in select result contains HTML contents, and I need to clean them.

How should add regexp_replace into my query so that I could clean the html content from source_body field?

Here is my original query looks like

SELECT
    final_set.conv_id,
    final_set.part_id,
    final_set.created_at,
    final_set.source_subject,
    final_set.source_body
FROM (
    (
        SELECT * FROM conversations cv
    )
    UNION
    (
        SELECT * FROM conversation_parts cp
        WHERE
            1 = 1
            AND cp.conversation_id in (
                SELECT cv.id FROM conversations cv)
            )
    ) final_set
WHERE
    1 = 1
    AND CASE WHEN '{{Subject}}' = 'Yes' THEN
        final_set.source_subject ILIKE '%{{Source Subject}}%'
    ELSE
        TRUE
    END
    AND final_set.created_at >= '{{From_Until.start}}'
    AND final_set.created_at <= '{{From_Until.end}}'
ORDER BY
    final_set.created_at ASC
0

There are 0 best solutions below