怎么left join前会有一个where????

解决方案 »

  1.   


     sql="select Top " + PageSize + " x.* from I_ToolPlan x   where  WTPROD between '"+a+"' and '"+b+"'   left join (select top "+PageSize*CurrentPage+" a.WTPROD,a.WTTOOL from I_ToolPlan a where  a.WTPROD between '"+a+"' and '"+b+"' order by WTPROD desc)y  on x.WTPROD=y.WTPROD and x.WTTOOL=y.WTTOOL where y.WTPROD is null order by x.WTPROD desc ";
      

  2.   

    WTPROD between '"+a+"' and '"+b+"' 放在 where后面WTPROD改為x.WTPROD
      

  3.   

     sql="select Top " + PageSize + " x.* from I_ToolPlan x   left join (select top "+PageSize*CurrentPage+" WTPROD,WTTOOL from I_ToolPlan where WTPROD between '"+a+"' and '"+b+"' order by WTPROD desc)y on x.WTPROD=y.WTPROD and x.WTTOOL=y.WTTOOL where x.WTPROD between '"+a+"' and '"+b+"' and y.WTPROD is null order by x.WTPROD desc ";
      

  4.   

    select Top " + PageSize + " x.*
           from I_ToolPlan x         
           left join (select top "+PageSize*CurrentPage+" WTPROD,WTTOOL from I_ToolPlan where  WTPROD between '"+a+"' and '"+b+"' order by WTPROD desc)y  on x.WTPROD=y.WTPROD and x.WTTOOL=y.WTTOOL 
    where x. WTPROD between '"+a+"' and '"+b+"'  and y.WTPROD is null 
    order by x.WTPROD desc "
      

  5.   

    把where 语句放后面就行了感觉