I have a table books with rows as below:
The genres field is an array of enum that contains the book genre, and these are its possible values: ['adventure', 'horror', 'romance']
| title | genres |
|---|---|
| Deadlock | {Horror} |
| Sunny Hills | {Romance, Adventure} |
| Exiled Prince | {Adventure} |
I tried:
SELECT * FROM books
WHERE genres = ARRAY['Adventure']::book_genres_enum[];
But that only returns the 'Exiled Prince' book.
How do I formulate a query for all rows containing 'Adventure' in its genres array?