Skip to content
Advertisement

PostgreSQL – Help comparing two tables against three specific columns

I need to match three columns across two tables. A query should select a row in t1 and search for any row in t2 where ALL three columns listed below match.

Here are the three columns

I’ve looked into a JOIN and UNION. UNION looks like it can rip out duplicates, but I wasn’t able to get it. Nor the join.

Seems like one of these two options are the way to go but I’m not clear on how to do it.

Also tried the following UNION

Ultimately, I’m trying to find out what network information from t1 does not exist in t2. t1 is a source of truth. t2 contains data in a production system.

Data from t1 will dynamically be updated into t2, but due to heavy rate limiting on the system where t2’s data comes from I’m trying to clean it up before running the API calls.

Advertisement

Answer

I’m trying to find out what network information from t1 does not exist in t2

That’s precisely what the NOT EXISTS operator is for:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement