Seti Net
Seti Net

Reputation: 743

SQL - Testing dB

I have a MySQL database that is not setup correctly. I need a Query that will help me find out where.

Two tables Table1.xyz_ID Table2.xyz_ID

Some entries in Table1.xyz_ID have no corresponding field in Table2.xyz_ID What is the SQL to sort Table2 entries that are in error?

Upvotes: 1

Views: 51

Answers (1)

drunken_monkey
drunken_monkey

Reputation: 1858

select t1.xyz_ID
from Table1 t1
left join Table2 t2
  on t1.xyz_ID = t2.xyz_ID
where t2.xyz_ID is null

Provides all IDs that are in Table1 but not in Table 2

Upvotes: 1

Related Questions