我有这样的表:
如果只选择SQL选择所有注释,对于具有'xxx'类型的曲目?
答案 0 :(得分:0)
嗯,你可以先做两件事:
SELECT commmentId, content, date
FROM comments
WHERE trackId IN (SELECT trackId
FROM tracks
WHERE genreId = xxx);
或者:
SELECT c.commentId, c.content, c.date, t.genreId
FROM comments c
INNER JOIN tracks t
ON c.trackId = t.trackId
WHERE t.genreId = xxx;
如果您想通过genreId或类型名称选择评论(如果您想通过名称进行选择,而不是将其扩展一点),我也无法理解,但这是您应该的逻辑休耕...