You cannot do this easily in MySQL .
The problem is that the βlikeβ relationship, as you define it, is not transitive. In your example, Smith Inc is similar to John Smith (for SSN ), and John Smith is similar to Jane Smith (in name), but Smith Inc not similar to Jane Smith . Thus, there is no single value with which all records can be compared, and GROUP BY will not help here.
On other systems that support recursion, you can construct a transitive closure of this relationship that would allow grouping, but this is not an easy task in MySQL .
source share