2010-03-27 7 views
0

j'ai deux tablesnombre sql() requête pour les tables

table1 champs

 fid,fname,fage 
     a ,abc ,20 
     b ,bcv ,21 
     c ,cyx ,19 

table2 champs

 rcno,fid,status 
    1 ,a ,ok 
    2 ,c ,ok 
    3 ,a ,ok 
    4 ,b ,ok 
    5 ,a ,ok 

je veux afficher Recteurs comme ce

 fid from table1 , count(recno) from table 2 and fage from table1   

    fid,count(recno),fage 
    a ,3   ,20 
    b ,2   ,21 
    c ,1   ,19 

j'essaye beaucoup de requêtes sql mais ai l'erreur

Merci

Répondre

1

Vous pouvez essayer

SElECT t1.fid, 
     COUNT(t2.fid), 
     t1.fage 
FROM Table1 t1 INNER JOIN 
     Table2 t2 ON t1.fid = t2.fid 
GROUP BY t1.fid, t1.fage 
+0

Ajouter une virgule après le compte :) –

+0

vrai, désolé, il a fait en notepad ++ X-) –

Questions connexes