表建的有问题啊,表b少一个母亲ID的字段

解决方案 »

  1.   

    表B的ID就是母亲的ID  childno 是孩子ID
      

  2.   

    1、
    select mothername from a where id in(select id from(select id,count(*) count from b group by id) where count=2)
    2、
    select mothername from a where id in(select id from(select id,count(*) count from b group by id having childsex=0) where count=2)
      

  3.   

    第二个改一下:
    select mothername from a where id in(select id from(select id,count(*) count from b where childsex=0  group by id ) where count=2)
      

  4.   

    1、
    select mothername from a ,(select id from(select id,count(*) count from b group by id) where count=2) c where a.id=c.id 2、
    select mothername from a ,(select id from(select id,count(*) count from b group by id having childsex=0 and count=2) c where a.id=c.id