select count(*) from b,a where b.aid=b.id
SELECT count(b.aid) FROM b as bLEFT JOIN a as aON b.aid = b.id