I have two tables, Table1 and Table2. I want to select distinct rows in Table2 that are not contained in Table1. Here is an example:
Table1
| A | | sem|
------------------
1. | aa | | 1 |
---------------
2. | bb | | 1 |
----------------
3. | aa | | 2 |
-----------------
4. | cc | | 2 |
---------------
Table2
| B |
------
1. | aa |
------
2. | aa |
------
3. | bb |
------
4. | cc |
------
5. | cc |
------
6. | ee |
------
7. | ee |
------
I would want the those row who is not common in this two table when sem = 1
like
output for sem = 1
result
| B |
- | cc |
- | ee |
You can do this with an
outer joinand awhereclause. In this case, a right outer join, I think: