r/learnSQL • u/Holyporcupines • Oct 30 '25
How to create a complicated join key
I've reached a problem joining two data sets as they don't have a great way to relate them
In table 1 I have a list of countries, but their names don't exactly match to table 2's list.
Example: Table 1 contains a country name, and a unique number to identify the country
[Iran (Persia), 630)
Table 2 only has a country name [Iran (Islamic Republic of)]
What is the best way to join these two tables? Unfortunately this is not the only case of country names not matching. Originally I was thinking about creating a joint key using the unique country identifier, but I'm not sure how to go about doing it with this large of data.
View all comments
Show parent comment
1
u/mikeblas Oct 30 '25
If you can't modify the tables, then you'll have to make an equivalency table and join through that.
I don't know what a GWNo number is, so maybe that's what you've already done.