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/Holyporcupines Oct 30 '25
Unfortunately neither of these tables can meaningfully be altered. I ended up creating a table of GWNo numbers, matching what could be matched and now I'm slowly going through and altering. Went from 18000 rows of data down to 1500. I'm sure there's a better approach but I can't see another.