I have two tables with binding primary key in database and I desire to find a disjoint set between them. For example,
Table1
has columns (ID, Name
) and sample data: (1 ,John), (2, Peter), (3, Mary)
Table2
has columns (ID, Address
) and sample data: (1, address2), (2, address2)
So how do I create a SQL query so I can fetch the row with ID from table1
that is not in table2
. In this case, (3, Mary)
should be returned?
Ps. The ID is the primary key for those two tables.
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…