我的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;
希望有人能帮助我,提前谢谢。