1. select count(t1.id) from table1 t1 where t1.id = (select t2.id from table2 t2 where t2......);
2. select count(t1.id) from table1 t1,table2 t2 where t1.id = t2.id and t2......;
ÎÊÏÂ,Õâ2ÖÐд·¨¶¼¿ÉÒÔ´ïµ½»ã×ܱí1µÄÄ¿µÄ°É? ÄÇÓÐÐÔÄÜÉϵÄÇø±ðÂð? Èç¹û²»ÊÇcount(),¶øÊÇt1.ÆäËû×Ö¶ÎÄØ?»¹ÓÐÇø±ðÂðË¿ìËÂý¿´Ö´Ðмƻ® µÚÒ»ÖÖд·¨Óдí°É =Òª¸ÄΪin ÎÒÈÏΪµÚ¶þÖֺõ㠻¹Òª¿´idÔÚt2±íÖеÄΨһÐÔ Èç¹ûÓÐÖØ¸´ÖµµÄ»°£¬µÚ¶þÖÖ²»×¼È· ²»Öظ´µÄ»°ÊÇÒ»ÑùµÄ ¿ÉÒÔ½«µÚÒ»ÖÖд·¨¸ÄΪ select count(t1.id) from table1 t1 where exists(select 1 from table2 t2 where t2...... and t2.id=t1.id);