I'm an experienced SWE, just new to SQL and would love a walkthrough on how to solve this particular problem.
I have an input table of name pairs. I need to determine if each pair of names are nicknames of each other or not:
left | right | desired |
---|---|---|
john | johnathon | True |
jon | john | True |
john | amy | False |
etc... | etc.. | etc... |
To do this, I have at my disposal a lookup table that links together canonical names and nicknames:
canonical_name | nickname |
---|---|
johnathon | jon |
johnathon | john |
john | jon |
etc... | etc.. |
What SQL query would get me there? Something with JOINs and IN statements I'm guessing, but I haven't gotten anything to work. I'm using DuckDB, but I'm guessing the solution is going to be general enough that the dialect of SQL shouldn't matter? Thank you!