incorrect result when filtering by association I have a docket, which has many entries. I want only dockets, where none of the associating entries contains the text "PENDING". For example, if docket A has 10 entries, and one of those entries' docket_type varchar field contains the word "PENDING" anywhere, then I don't want that docket.

This is my solution:

SELECT * FROM dockets
INNER JOIN entries 
ON entries.docket_id = docket.id 
WHERE (docket_type NOT LIKE '%PENDING%')


The problem is, while it does not retrieve entries that contain that text, it still retrieves the associating dockets, when those dockets contain other entries that do not contain that text. I don't want to retrieve the docket if one of its entries contains this text in docket_type. 

How could I fix this?
You need one more join (a LEFT join with IS NULL check) or a NOT EXISTS subquery and to move the condition (reversed!) there:

SELECT * FROM dockets
INNER JOIN entries 
ON entries.docket_id = docket.id 
WHERE NOT EXISTS
      ( SELECT 1
        FROM entries AS e
        WHERE e.docket_id = docket.id 
          AND e.docket_type LIKE '%PENDING%'
      ) ;