我的 SQL 查询有一些问题。我试图选择每个听某位艺术家的用户,在这种情况下是莱昂国王。
这是我的查询,它有效:
SELECT *
FROM artists, tracks, playcount
WHERE playcount.songid = tracks.id
AND tracks.artistname = artists.name
AND artists.name = "Kings of Leon";
上面查询的问题是我得到了相同用户的几条记录。现在我想选择每个唯一的用户名,这个查询不起作用:
SELECT DISTINCT playcount.user
FROM artists, tracks, playcount
WHERE playcount.songid = tracks.id
AND tracks.artistname = artists.name
AND artists.name = "Kings of Leon" LIMIT 0,10;
希望有人可以帮助我,在此先感谢。