Postgresql – Specific text search in SQL

postgresql

For an assignment, we are doing select statements using Shakespeare's works in PG Admin. I must find which character, and in what work, said a specific phrase. I'm stuck with the following code:

select workid, charid from paragraph

where plaintext like 'rose'

In which I'm trying to find who said "A rose by any other name would smell as sweet." Any tips?

Best Answer

Figured it out. Because the line given isn't the same as written, the following query worked:

select workid, charid, wordcount from paragraph
where plaintext like '%rose%'
and plaintext like '%other%'
and plaintext like '%name%'
and plaintext like '%smell%'
and plaintext like '%sweet%';