I have two tables here:
Table 1
Name | Longname1 | Longname2
'John' | 'Johnny' | 'Johnson'
'Kate' | 'Katie' | 'Kathryn'
I have another table
Table2
Name | Area1 | Area2
'John' | 'Texas' | 'Alabama'
'Kate' | 'California' | 'Virginia'
Actually Table1.Longname1 and Table2.Area1 should be linked together, so as Table1.Longname2 and Table2.Area2. However it is not related in postgres.
Here is my trouble
- How could I add back the relationship in the table?
If I would like to form a single query which will
a) Input is 'Johnny' (Table1.Longname1) and the output is 'Texas'(Table2.Area1)
b) Input is 'Johnson' (Table1.Longname2) and the output is 'Alabama'(Table2.Area2)
Which the query itself would link the relationship for me? Is it possible?
Thanks in advance