I have two tables:
Table tablefoo
contains a column fulldata
.
Table tablebar
contains a column partialdata
.
I want find a list of tablefoo.fulldata
that do NOT have partial matches in tablebar.partialdata
.
The following provides a list of tablefoo.fulldata
with partial matches in tablebar
, but I want the negative of this.
select fulldata from tablefoo
where fulldata like any (select '%' || partialdata from tablebar);
This lists every record in partialdata
:
select fulldata from tablefoow
where partialdata not in (select '%' || partialdata from tablebar);
Any idea how to get only the results tablefoo.fulldata
that do not contain matches to a leading wildcarded tablebar.partialdata
?
I found this link: PostgreSQL 'NOT IN' and subquery which seems like it's headed down the right path, but I'm not getting it to work with the wildcard.
Sure, I could write a script to pull this out of psql and do the comparisons, but it would be much nicer to handle this all as part of the query.