select  distinct * from 
mytable a ,yourtable b, othertable c
where a.del=b.del 
and b.del=c.del 
and a.del=1

解决方案 »

  1.   

    select mytable.*,b.* from mytable join 
                 (select yourtable.* ,c.*  from yourtable join 
                    (select * from othertable where del=1)c 
                         on yourtable .del=c.del)b
                     on mytable.del=b.del
      

  2.   

    我也以为你的要求是把多条记录连接到一起,照那样一楼的答案是对的!我做的那个也是想把多条记录连接到一起,我用到连接,只是因为觉得连接的效率会高一些!呵呵,不过我写错了!你的意思不是把记录连起来吗?如果纯粹是分开查询出del=1的记录,那就简单多了!
      

  3.   

    比如,mytable里面有1条,yourtable里面有2条,othertable里面有3条,那么查出来就是1+2+3=6条记录
    三个表没有关系,只有del字段是一样的,不是1就是0
      

  4.   

    三个表的结果是一样的吗?如果是:
    select mytable.* where del=1
    union all 
      select yourtable.* where del=1
     union all 
       select othertable.* where del=1
    如果不一样:
    select mytable.* where del=1
    select yourtable.* where del=1
    select othertable.* where del=1
      

  5.   

    应该是:
    三个表的结构是一样的吗?如果是:select mytable.* from mytable where del=1
    union all 
      select yourtable.* from yourtable where del=1
     union all 
       select othertable.* from othertable where del=1
    如果不一样:
    select mytable.* from mytable where del=1
    select yourtable.* from yourtable where del=1
     select othertable.* from othertable where del=1
    老出错哦!