G
Gummball
Hello!
I need some help with a query I'm trying to write. I have two tables with
customer information, tblA and tblB with unique identifiers tblA.id and
tblB.id. I'm trying to write a query to return results of everyone in tblA
who is NOT in tblB and vice versa. Here is an example:
tblA
----------
| ID |
----------
| 1 |
| 2 |
| 5 |
----------
tblB
----------
| ID |
----------
| 2 |
| 3 |
| 5 |
----------
Since 2 and 5 appear in both tables, 1 in tblA only, and 3 in tblB only, the
query should return:
qryAB
-------------------
| ID | tbl |
-------------------
| 1 | A |
| 3 | B |
-------------------
I've written a big jumbled mess of unions and joins aggregating all possible
values of ID then joining each of A and B, resulting in this:
----------------------------
| ID | tblA | tblB |
----------------------------
| 1 | A | |
| 2 | A | B |
| 3 | | B |
| 5 | A | B |
----------------------------
Then I took all values of ID where either tblA or tblB is null.
This gets me to the data set I need, but I'm wondering if there's an easier
way to do it?
Thanks for any help!
I need some help with a query I'm trying to write. I have two tables with
customer information, tblA and tblB with unique identifiers tblA.id and
tblB.id. I'm trying to write a query to return results of everyone in tblA
who is NOT in tblB and vice versa. Here is an example:
tblA
----------
| ID |
----------
| 1 |
| 2 |
| 5 |
----------
tblB
----------
| ID |
----------
| 2 |
| 3 |
| 5 |
----------
Since 2 and 5 appear in both tables, 1 in tblA only, and 3 in tblB only, the
query should return:
qryAB
-------------------
| ID | tbl |
-------------------
| 1 | A |
| 3 | B |
-------------------
I've written a big jumbled mess of unions and joins aggregating all possible
values of ID then joining each of A and B, resulting in this:
----------------------------
| ID | tblA | tblB |
----------------------------
| 1 | A | |
| 2 | A | B |
| 3 | | B |
| 5 | A | B |
----------------------------
Then I took all values of ID where either tblA or tblB is null.
This gets me to the data set I need, but I'm wondering if there's an easier
way to do it?
Thanks for any help!