Say I have 2 tables that are joined on 5 fields that exist in both tables:
CROSS JOIN that creates a full cross-product between the two tables. Then add up the number of columns that match between each pair of records.
SELECT t1.*, t2.*, t1.firstname = t2.firstname + t1.lastname = t2.lastname + t1.address = t2.address + t1.city = t2.city + c1.country = t2.country AS num_fields_matching FROM Table1 AS t1 CROSS JOIN Table2 AS t2