My SQL knowledge is a bit more limited than I’d like to admit. What I’m attempting to do is query a single table. In that table I want to return and group items with the same "name" (column), but only if their "address" (column) DOESN’T match. I have been trying to find existing SO questions, because I’m sure someone has faced this same issue, but my searches haven’t yielded good results.
ID Name Address
--- --------- ------------
1 Tom 123 Fake St.
2 Paul 81 Second Ave.
3 Mark 1001 Market St.
4 Tom 123 Fake St.
5 Tom 903 Castle St.
6 Pete 14 Circle Dr.
The expectation would be that I could return the results for "Tom" for both of his addresses, because he has more than 1, and because they don’t match.
ID Name Address
--- --------- ------------
1 Tom 123 Fake St.
4 Tom 123 Fake St.
5 Tom 903 Castle St.
2
Answers
This will give you a list of names with different address
This will give you the results you asked for
You can use correlated subqueries to caclulate the umber of entires
Or a MySql 8 Version of that
fiddle