I have 3 table related in sqlite: first to second table related 1 to many, and each record of second table is relate to many record into third table. I'm using this query for take all element of first table and count of all element into second table for each element of first tablle, example:
CREATE TABLE TRACK_NAME(
NAME_TRACK TEXT,
trackid INTEGER,
FOREIGN KEY(trackid) REFERENCES track(trackid)
);
CREATE TABLE track(
trackid INTEGER,
trackname TEXT,
trackartist INTEGER,
FOREIGN KEY(trackartist) REFERENCES artist(artistid)
);
CREATE TABLE artist(
artistid INTEGER PRIMARY KEY,
artistname TEXT
);
so i use this query for take all artist and do a count of tracklist for each artist:
SELECT a.artistname,
(SELECT COUNT(*) FROM track t
WHERE t.trackartist = a.artistid)
FROM artist a
now i would like to implement this query for take for each tracklist the name_track that are into third track_name table?
thanks
Aucun commentaire:
Enregistrer un commentaire