Skip to content
Advertisement

Comparing two tables without foreign key [closed]

There are two tables in 2 different databases one table consists of Salutations example Mr, Miss and other table has names with Salutation example Mr.XYZ, Miss.ABC so I need a query which will compare the two tables and gives only those names from table 1 which are of matching salutations.

Example :

So the query needs to compare two tables and give the output as

Advertisement

Answer

I think you want join query with like:

The one caveat is that this can return more than one match. For instance, anything that matches “Mr. & Mrs.” would also match “Mr.”. To fix this, you can choose the longest match, using apply:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement