Serious SQL – Data with Danny Day 7

365 Days of Daily Coding – Day 166

It’s been a productive day today. I have been reading a lot on SEO lately cause I have officially transitioned from a fintech industry to a digital commerce industry. My first job was at a digital commerce industry so I am quite familiar with the basic/foundational knowledge of the industry and unlike at SWIFT, the business and terminonlogies are fairly easy to understand.

Today, I recapped another advanced joins which is called ANTI JOIN. It’s a join which selects records from the base table that doesn’t exist in the target table. Below is basically an example of how you could implement an ANTI JOIN without using the syntax as not all flavors of SQL support the syntax. It can be achieved using WHERE NOT EXISTS.

SELECT
  names.iid,
  names.first_name
FROM names
WHERE NOT EXISTS (
  SELECT 1
  FROM new_jobs
  WHERE names.iid = new_jobs.iid
);

Leave a comment