Using sqlite3, I have a table that looks like this:
+---------+-----------------+----------+-----------+--------+
| ArtId | Location | ArtistID | Title | Size |
+---------+-----------------+----------+-----------+--------+
| 3 | China | 400 | birds | small |
| 4 | Samoa | 670 | stars | large |
| 5 | Chile | 427 | clouds | medium |
| 6 | US | 427 | clouds | small |
| 7 | France | 123 | collage | small |
| 8 | Spain | 123 | collage | large |
| 9 | Belarus | 123 | collage | medium |
+---------+-----------------+----------+-----------+--------+
I have a query that produces all the results where the only results are ones with duplicate titles and artists:
SELECT *
FROM LiveArt c1, (SELECT Title, ArtistID FROM LiveArt GROUP BY Title, ArtistID) c2
WHERE c1.Title = c2.Title AND c1.ArtistID = c2.ArtistID
to produce the following table:
+---------+-----------------+----------+-----------+--------+
| ArtId | Location | ArtistID | Title | Size |
+---------+-----------------+----------+-----------+--------+
| 5 | Chile | 427 | clouds | medium |
| 6 | US | 427 | clouds | small |
| 7 | France | 123 | collage | small |
| 8 | Spain | 123 | collage | large |
| 9 | Belarus | 123 | collage | medium |
+---------+-----------------+----------+-----------+--------+
What I want returned is this:
+---------+-----------------+----------+-----------+--------+
| ArtId | Location | ArtistID | Title | Size |
+---------+-----------------+----------+-----------+--------+
| 6 | US | 427 | clouds | small |
| 8 | Spain | 123 | collage | large |
| 9 | Belarus | 123 | collage | medium |
+---------+-----------------+----------+-----------+--------+
How can I tweak my query to do that (skip the first matched result)?
1 Answer