我有3个表(SQL Server)。
表1. ComentListaDef(指评论)
表2. ListaDefeito(指DefectList)
表3. RespostaComentListaDef有关另一个表的SQL查询结果为空
我需要做的是给我带来一个查询(手段有关评论回答)所有“ComentListaDef.Comentarios”,“RespostaComentListaDef.IdAutor”没有回答。
我想查看与“RespostaComentListaDef.IdAutor”有关的所有“ComentListaDef.Comentarios”为空。
我试图做这个查询,但它不工作。
“ComentListaDef”是指“评论”和“RespostaComentListaDef”是指“答案”。我试图列出作者与Id =的所有评论? (RespostaComentListaDef.IdAutor)没有回答。
SELECT ComentListaDef.Comentarios, COUNT(RespostaComentListaDef.IdAutor)
FROM ComentListaDef
INNER JOIN ListaDefeito ON ComentListaDef.IdListaDefeitos = ListaDefeito.Id
LEFT JOIN RespostaComentListaDef on ComentListaDef.Id = RespostaComentListaDef.IdComentListaDef
WHERE ListaDefeito.IdRevisor = 1075
AND ComentListaDef.IdListaDefeitos = 36
AND RespostaComentListaDef.IdAutor = 1072
GROUP BY ComentListaDef.Comentarios HAVING COUNT(RespostaComentListaDef.IdAutor) = 0
它运作良好!谢谢!!我不得不为我想要的添加更多东西,但效果很好!谢谢!!!!! – Victor