select a , b ,c,i,j  from tbl where i=1 
如果执行搜索无结果,再与j=1搜索,怎样在一条sql 中处理这个搜索级别的问题??

解决方案 »

  1.   

    select a , b ,c,i,j  from tbl where i=1 
    union 
    select a , b ,c,i,j  from tbl where j=1 (where not exists select 1 from tb1 where i=1)
      

  2.   

    sorry
    select a , b ,c,i,j  from tbl where i=1 
    union 
    select a , b ,c,i,j  from tbl where j=1 and not exists (select 1 from tb1 where i=1)
      

  3.   

    按照1楼兄弟的方法, 我撈到了两条record , 我在j=1 这里明明只有一条结果, 不过把连i=1 这条数据都捞出来了, 能帮我再完善一下吗?
      

  4.   

    如果你查到了2条数据,建议仔细查看你的数据,union 不会出来重复的数据的。一定是j=1或者i=1 有两条数据。