经过跟踪发现查询语句可能存在问题
SELECT FPLANID, FCLIENTACCOUNT, FPARENTPLANID, FPLANROOTID, FPLANCODE, FPLANTITLE, FPLANTYPEID, FPLANTYPENAME, FTIMESPANID, FTIMESPANNAME, FPLANSTATE, FPLANDESCRIPTION, FCREATETIME, FCHANGETIME, FPLANBEGINTIME, FPLANFINISHTIME, FFACTBEGINTIME, FFACTFINISHTIME, FPLANPERCENT, FFACTPERCENT, FPERCENTMODE, FPLANCYCLE, FFACTCYCLE, FPLANMANHOUR, FFACTMANHOUR, FFINISHMODE, FFINISHMODENAME, FPLANYEAR, FPLANMONTH, FPLANWEEK, FCREATORID, FCREATORNAME, FCREATORDEPTID, FCREATORDEPTNAME, FPRINCIPALID, FPRINCIPALNAME, FPRINCIPALDEPTID, FPRINCIPALDEPTNAME, FSAFELEVEL, FPIECE, FAMOUNT, FAFFIRMOPERATION, FAFFIRMOPERATIONSTATE, FPLANSORTCODE, FADJUSTPLANID, FADJUSTROOTPLANID, FTREECODE, FBIZTYPEID, FBIZTYPENAME, FCREATORPOSID, FCREATORPOSNAME, FPRINCIPALPOSID, FPRINCIPALPOSNAME
FROM TPLAN
WHERE ((TPLAN.FCLIENTACCOUNT = 'DONGEEJIAO')) and ((TPLAN.FPLANROOTID IN (SELECT DISTINCT FPLANROOTID FROM TPLAN WHERE (((TPLAN.FPLANBEGINTIME >= '2007-5-1') AND (TPLAN.FPLANBEGINTIME < '2007-6-1') OR (TPLAN.FPLANFINISHTIME >= '2007-5-1') AND (TPLAN.FPLANFINISHTIME < '2007-6-1')) AND (TPLAN.FPLANSTATE IN ('psPlanEditing', 'psPlanExecuting', 'psPlanFinished'))) AND (FPLANID IN (SELECT DISTINCT TPLANEXECUTOR.FPLANID FROM TPLANEXECUTOR, TPLAN WHERE (TPLAN.FPLANID = TPLANEXECUTOR.FPLANID) AND ((FPERSONID IN ('LINGM')) OR ((FORGURL LIKE '\ROOT\GFGS.OGN\XXJSB.DPT%'))))))) AND (NOT(TPLAN.FPLANSTATE IN ('psPlanDeleted'))))
ORDER BY TPLAN.FPLANBEGINTIME DESC, TPLAN.FCREATETIME DESC
是不是应该把查询条件中((TPLAN.FPLANBEGINTIME >= '2007-5-1') AND (TPLAN.FPLANBEGINTIME < '2007-6-1') OR (TPLAN.FPLANFINISHTIME >= '2007-5-1') AND (TPLAN.FPLANFINISHTIME < '2007-6-1'))
改为(在or的前后增加了一对括号):
((((TPLAN.FPLANBEGINTIME >= '2007-5-1') AND (TPLAN.FPLANBEGINTIME < '2007-6-1') )OR ((TPLAN.FPLANFINISHTIME >= '2007-5-1') AND (TPLAN.FPLANFINISHTIME < '2007-6-1'))) |