我需要进行复杂的查询。我有表:
CREATE TABLE IF NOT EXISTS tracks
( id INTEGER PRIMARY KEY, path TEXT,
title TEXT, artist TEXT,
album TEXT, genre TEXT,
duration INTEGER, rating INTEGER );
对不起,问题的肮脏标题,但我不明白如何更简短地解释它。
问题:如何显示请求艺术家的专辑列表,并为每个显示的专辑计算单个查询中当前专辑中请求艺术家的曲目数。
我尝试过这样的事情:
SELECT albtbl.album as album, albtbl.artist as artist,
( SELECT count(*) FROM trackstbl WHERE trackstbl.artist = albtbl.aritst ) as tracksCount
FROM ( SELECT tbl.album as album, tbl.artist as artist, count(title) as tracksCount FROM tracks as tbl WHERE tbl.artist = 'requested_artist'
GROUP BY tbl.album ) as albtbl, FROM tracks as trackstbl ORDER BY album ASC
但它没有编译:
SQLiteException:在“FROM”附近:语法错误: