没有6*6那么多吧。这样行不?select * from job where id=@id 
    and (@jobid is null or jobid=@jobid) 
    and (@comid is null or comid=@comid)

解决方案 »

  1.   

    这样行不行select * from job where id=@id 
        and isnull(jobid,@jobid)=@jobid and isnull(comid,@jobid)= @jobid 
      

  2.   

    这样行不行select * from job where id=@id 
        and isnull(jobid,@jobid)=@jobid and isnull(comid,@jobid)= @jobid 
      

  3.   

    select * from job where id=@id and jobid=(case  when @jobid is null then jobid else @jobid end) and comid=(case when @comid is null then comid else @comid end )
    试试看这样,这样应该可以吧
      

  4.   

    试试看这样,肯定可以了:
    select * from job where id=isnull(@id,id) and jobid=isnull(@jobid,jobid) and comid=(@comid,comid)
      

  5.   

    select * from job 
    where id=isnull(@id,id)
          and 
          jobid=isnull(@jobid,jobid)
          and 
          comid=isnull(@comid,comid)