1
Dear friends, good afternoon.
I have a table that stores the texts of messages exchanged by email and I need to identify the emails that comes with a set of words, for example:
For any message that displays the combinations ['Merged' and 'closed'], ['merged' and 'Closed'], ['Merged' and 'closed'] would identify as 1.
I tried the following query:
select distinct
ticket_id,
1 as mesclado
FROM conversation c
WHERE
((body_text LIKE ('%Mesclado%') OR body_text LIKE ('%mesclado%')) and body_text LIKE ('%fechado%'))
OR ((body_text LIKE ('%merged%') OR body_text LIKE ('%Merged%')) and body_text LIKE ('%closed%'))
OR ((body_text LIKE ('%mesclados%') OR body_text LIKE ('%Mesclados%')) and body_text LIKE ('%fechado%'))
The expected result would be a table in the following configuration:
What result do you expect from yours
query
? Add a practical example in http://sqlfiddle.com/– Tiedt Tech
The result was not as expected? It would not be simpler to do, for example,
WHERE
(lower(body_text) LIKE '%mesclado%' and lower(body_text) LIKE '%fechado%')
OR (lower(body_text) LIKE '%merged%' and lower(body_text) LIKE '%closed%') 
OR (lower(body_text) LIKE '%mesclados%' and lower(body_text) LIKE '%fechado%')
? Or, depending on the DBMS used, work with regular expressions? If it will always be listed only the merged field with value 1 why list it?– anonimo