Search code examples
mysqlsqllinqpad

MySQL - Searching 1 table for missing values


I have 2 tables, one with customer addresses, one with postal codes and their corresponding "geographical region".

The Postal Codes table is missing over 100 postal codes that can't be matched with the customer address postal code.

I'm trying to find a way to search for all records that the customer address postal code is not in the postal codes table.


Solution

  • Firstly select distinct postal codes from postal code table then write query like : select * from customer address where postal code not in (select distinct postel code from postal code table)