[英]sql count() query for tables
我有兩張桌子
table1欄位
fid,fname,fage
a ,abc ,20
b ,bcv ,21
c ,cyx ,19
table2欄位
rcno,fid,status
1 ,a ,ok
2 ,c ,ok
3 ,a ,ok
4 ,b ,ok
5 ,a ,ok
我想顯示這樣的整流器
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
我嘗試許多sql查詢,但出現錯誤
謝謝
你可以試試
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.