I'm trying to write a SQL Query for the below. I have list of email address in table. I need to pull Subscriber key associated to that email address from another table if that email address is not present I want email address as subscriber key. How to write SQL for this? Any help will be highly appreciated.
Table1
**| Email ID**
| TOM@gmail
| KIM@gmail
| JIM@gmail
| RIM@gmail
| SIM@gmail
Table2
Subscriber key | Email ID**
100222221 | TOMMOT@gmail
103333332 | KIM@gmail
104444443 | JIMMIJ@gmail
Output:
Subscriber key | Email ID**
100222221 | TOMMOT@gmail
103333332 | KIM@gmail
104444443 | JIMMIJ@gmail
RIM@gmail | RIM@gmail
SIM@gmail | SIM@gmail