See attached file.
My question is more related to SQL, I am not familiar with database, so I am trying to describe my goal as clearly as possible.
Two tables: Table 1 and Table 2, table 1 has 3 fields and table 2 has 3 fields.
Now I have two queries: query 1 is based on table 1 only; query 2 is based on table 2 only. Query 2 is the result when "ABC=63 and XYZ=K0"; query 1 is the result when "ABC=63". Table 1 does NOT have the field XYZ, so it is not able to set XYZ=K0.
The result in query 2 field DEF is unique, there is no duplicate; but for query 1, there are duplicates in field DEF, you can see 3 R1, 3 R2, 2 R3, 2 R4, 2 R5.
Table 1 is a much bigger set, table 2 is smaller set, the joint set is {R2,R3, R4}.
{R1, R5}: In query 1 but not in query 2
{R7}: In query 2 but not in query 1
The joint set is the exact information I need, based on these two tables, how should I write the SQL code to get the result? I mean the code like: SELECT .... FROM .... WHERE.....; Since it is big database, there are also many rows in query 2, so I can NOT change query 1 by adding "DEF=R2 or DEF=R7 or DEF=R3 or DEF=R4".
I do mean SQL code, since I would like to pull the joint set automatically (programming).
Any comments?