0
SELECT EMPID,e.CUR_VC_FIRSTNAME_NN,d.DEPTNAME,LTID,FROMLEAVEDATE,FROMLEAVETYPE,TOLEAVEDATE,TOLEAVETYPE,NUM_LEV_DAYS 
FROM lmsdb.leaves l,lmsdb.department d,lmsdb.emp_pas_data e 
WHERE l.EMPID=e.cur_c_empno_pk 
    AND d.DEPTID=e.CUR_C_DEPT_CD_CFK 
    AND empid IN (SELECT cur_c_empno_pk 
                  FROM lmsdb.emp_pas_data 
                  WHERE uni_vc_unit_desc_nn='Hyderabad') 
    AND LEV_STATUS='2' 
    AND TOLEAVEDATE>'2013-06-27' 
    AND FROMLEAVEDATE<'2013-07-28' 
ORDER BY d.DEPTNAME,EMPID ASC;

这是我正在使用服务器 2003 的查询。当我使用 windows xp mysql 时,相同的查询它工作正常。

4

1 回答 1

0
SELECT EMPID,e.CUR_VC_FIRSTNAME_NN,d.DEPTNAME,LTID,FROMLEAVEDATE,FROMLEAVETYPE,TOLEAVEDATE,TOLEAVETYPE,NUM_LEV_DAYS    
FROM lmsdb.leaves l,  
     lmsdb.department d,  
     lmsdb.emp_pas_data e   
WHERE l.EMPID=e.cur_c_empno_pk   
        AND d.DEPTID=e.CUR_C_DEPT_CD_CFK   
        AND e.uni_vc_unit_desc_nn='Hyderabad')   
        AND LEV_STATUS='2'   
        AND TOLEAVEDATE>'2013-06-27'   
        AND FROMLEAVEDATE<'2013-07-28'  
ORDER BY d.DEPTNAME,EMPID ASC;

您的查询看起来正确。您应该检查表 lmsdb.leaves 或 lmsdb.emp_pas_data 中的重复行

于 2013-07-19T17:13:45.783 回答