Say I have two tables: table1 as follows
Name |Surname| col1
------------------------
Bob |Smith | BS1
Mary Jane|Jones | MJ1
and table2 as follows:
Name |Surname | col2
------------------------------
Bob |Keller Smith | BS2
Mary |Jones | MJ2
What I would like is to JOIN these together to obtain:
Name |Surname | col1| col2
-------------------------------------
Bob |Keller Smith | BS1 | BS2
Mary |Jones | MJ1 | MJ2
I tried:
SELECT tableb.Name, tableb.Surname, tablea.col1, tableb.col2
FROM table1 as tablea
LEFT JOIN table2 as tableb
ON '%'+tablea.Name+'%' LIKE '%'+tableb.Name+'%' AND '%'+tablea.Surame+'%' LIKE '%'+tableb.Surame+'%'
But these seemed to join everything.
How can I join together columns with wildcards correctly?