I have a table with the columns id,artist_id,web. I have found a query with which I can display web duplicates like so:
SELECT DISTINCT b.artist_id AS artist1, b.web AS web1, a.artist_id AS artist2, a.web AS web2 FROM artist_webs a INNER JOIN artist_webs b ON b.web=a.web AND b.web!='NULL' AND b.artist_id!=a.artist_id
So, it displays different artists that have the same web address. The only problem though is that it displays entries that are essentially the same twice or more times. E.g., a result could look like:
Row 1
artist1: 21399
artist2: 1036
Row 2
artist1: 1036
artist2: 21399
Of course, for the database these are different entries, but it it obvious to a human being that they are the same as they refer to the same artist ids with the same web addresses. The first row would be enough.
So, all that is really needed is a modification of the query above that will display distinct rows regardless of the order in which the ids appear.
Thanks!
When joining on the same table I always add something like
instead of your
That way they are not only “not the same”, but also you skip on the ‘reverse’ sollution.