where 1=1
 if 文本区域=空 then
   and ....
 end if
 
 if 文本区域=空 then
   and ....
 end if

解决方案 »

  1.   

    use a parameter to store all of the conditions.each condition like: time > XXX an time < XXX  and use and to concat all of these conditions.
    you should have a basic query clause like 'select XXX from XXX where '
    at last, trim the right and of the conditions.
    you will get the final clause like:select XXX from XXX where condition1 and condition2 and conditionn...
      

  2.   

    SELECT *
    FROM news
    WHERE 1=1
    AND (adminid=@adminid OR @adminid='')
    AND (teacherid=teacherid OR @teacherid='')
    AND (Time BETWEEN @FROM AND @TO OR @FROM ='' AND @TO='')
    ORDER BY decode(@order,'time',time,'newsid',newsid,1)
      

  3.   

    @
    这个符号是什么意思?
    我怎么从来没见过?
    另外,问题已经解决了,思路和zhubo的差不多,谢谢大家!