jeudi 18 juin 2015

SQLite combine values of similar records into one

In my SQLite database I have a table called Tracks which is made up of the following columns: artist, track, genre1, genre2, genre3. The table contains many values which have the same artist and track values with different genre1, genre2, genre3 values. Like the example below:

artist | track   | genre1  | genre2 | genre3
ABBA   | Song 1  | Rock    | Rock   |  Rock
U2     | Song 4  | Rock    | Rock   |  Rock
ABBA   | Song 1  | Pop     | Pop    |  Pop
U2     | Song 4  | Pop     | Pop    |  Pop
ABBA   | Song 1  | 70s     | 70s    |  70s
U2     | Song 4  | 90s     | 90s    |  90s

I need to create an SQLite statement that will amalgamate all unique genre values where the artist and track are the same, like the example shown below:

artist | track   | genre1  | genre2 | genre3
ABBA   | Song 1  | Rock    | Pop    |  70s
U2     | Song 4  | Pop     | Rock   |  90s

Any help with this would be hugely appreciated.

Aucun commentaire:

Enregistrer un commentaire