The two tables in question are:
id | type ---|-------- 1 | XXX 2 | YYY
id | type | sub_type ---|-------|--------- 1 | XXX X | aaa 2 | XXX-Y | bbb 3 | YYY-X | ccc 4 | YYY.Y | ddd 5 | QQQ-G | fff 6 | RRR+Q | ggg
What I want is to use the
type column of
completed_types to filter
SELECT type FROM all_types WHERE type NOT LIKE ANY(SELECT type FROM completed_types.
The expected output based on the above tables would be:
id | type | sub_type ---|-------|--------- 5 | QQQ-G | fff 6 | RRR+Q | ggg
However it does not seem to remove any results from the output. I tried appending a wildcard '%' to the end of the subquery:
SELECT type FROM all_types WHERE type NOT LIKE ANY(SELECT type||'%' FROM completed_types)
But this has also not reduced the number of results.
My plan is to use this in a function, as
all_types.type could grow quickly while
completed_types.type will be slower, and will likely never be completely the same or even close, so if that would change your answer please let me know, but any help with this is appreciated.