select a.id from (select * from a where a.title=1) a,(select * from b where b.title=1) b where a.id=b.aid

解决方案 »

  1.   

    ERROR 1064: You have an error in your SQL syntax near 'select * from a where a.t
    itle=1) a,(select * from b where b.title=1) b where a.i' at line 1
      

  2.   

    select *
    from a
    inner join b on a.id=b.aid
    where 
    a.title=1 or b.title=1
      

  3.   

    SELECT distinct a.*,b.* FROM a left join b on a.id=b.aid WHERE (a.title=1 || b.title=1)
      

  4.   

    SELECT a.*,b.* FROM a left join b on a.id=b.aid WHERE (a.title=1 || b.title=1) group by a.id
      

  5.   

    select distinct a.id from a,b where (a.title=1 || b.title=1) && a.id=b.aid
      

  6.   

    select * from subtable where Id in (select max(s.id) from parenttable p,subtable s
    where s.parent_id  =p.id )
    可能效率不太高
      

  7.   

    看看SQL说明书,用LeftJoin还是rightJoin,俺忘了PHP建站技术讨论网站:www.myhosts.cn
      

  8.   

    select * from a where title in(select a.title from a a inner join b b on a.id=b.aid where a.title='1'and b.title='1')
      

  9.   

    嘿嘿,楼主的select a.id from a,b where (a.title=1 || b.title=1) && a.id=b.aid
    应该是对的,(最好 || => or , && => and )
    不认为出现重复结果是sql的问题,应该是数据本身就是有重复的
    如果要强制不重复,加distinct即可。
      

  10.   

    加过distinctrow,但是7M的数据表生生读死了。数据不会有重复,测试的时候就添了两条数据,读出来了十几条。请教,为什么“and”或“or”要比“&&”或“||”好?