表A字段id,name 
表B字段id,content 
现在要查询查表A的记录总数,条件是A.id=B.id 并且表B对应的记录条数为0,在线等了.... 
类似SELECT COUNT(*) 
FROM tb1,tb2 
WHERE tb1.id=tb2.id AND b.recordcount=0  这样的是完全错的....因为recordcount不能在sql直接这样运行... 
在线等...

解决方案 »

  1.   

    select count(*)
    from A
    where not exists(select * from B where A.id=B.id)
      

  2.   


    --这样吗?
    SELECT COUNT(*) FROM A WHERE ID NOT IN(SELECT ID FROM B)
      

  3.   


    select count(*)
    from tb1 A
    where not exists(select * from tb2 B where A.id=B.id)
      

  4.   

    select id,name from a where id not in(select id from tb2)
      

  5.   

    SELECT COUNT(distinct tb1.id) 
    FROM tb1,tb2 
    WHERE tb1.id=tb2.id AND b.recordcount=0
      

  6.   

    好象明白你的意思了.SELECT COUNT(*) FROM tb1 where id not in (select id from tb2)
      

  7.   


    1 SELECT COUNT(*) 
      FROM A 
      WHERE ID NOT IN(SELECT ID FROM B)2 select count(*)
      from A
      where not exists(select * from B where A.id=B.id)
    2的效率高於1