sql没有给我所有的行

时间:2016-08-10 18:55:02

标签: sql

我有一个基于一组条件收集信息的查询。当我运行查询时,它并没有得到我应该得到超过3000000的所有数据,但我只得到600000而且我不知道为什么?需要帮助

SELECT      dbo.mediainteraction.ani
            ,dbo.mediainteraction.createtime
            ,dbo.classificationcode.description
            ,dbo.employee.fullname
            ,dbo.employee.loginname
            ,dbo.mediainteraction.pkey
FROM        dbo.agentsegment
RIGHT JOIN  dbo.taskperformedcode
RIGHT JOIN  dbo.mediainteraction    ON dbo.taskperformedcode.pkey = dbo.mediainteraction.pkey
RIGHT JOIN  dbo.classificationcode  ON dbo.taskperformedcode.code_key = dbo.classificationcode.pkey 
                                    ON dbo.agentsegment.pkey = dbo.mediainteraction.pkey 
RIGHT JOIN  dbo.employee            ON dbo.agentsegment.employee_key = dbo.employee.pkey 
WHERE       (dbo.mediainteraction.createtime >= '2016-7-24')
AND         (dbo.mediainteraction.createtime < '2016-7-25')

1 个答案:

答案 0 :(得分:0)

正如其他人指出的那样,您需要逐步评论逻辑部分,直到找到问题为止。

但问题可能是由于在WHERE语句中使用了mediaineration.createtime,因为它涉及到RIGHT JOIN,因为它会使所有连接成为内连接