多表聯合查詢問題
nearest
nearest 2017-10-24 21:26:41
0
1
1264

select pid,count(*) from table1 group by pid;

查出每個pid 出現的總次數,

問題出來了,

另一個表裡放了pid對應的name,

現在需要透過聯合查詢,直接顯示出,

每個name出現的總次數 

nearest
nearest

我爱PHP

全部回覆(1)
路过

SELECT a.pid as pid, a.name as name, COUNT(b.pid) as num FROM `table1` as a, `table2` as b WHERE a.pid = b.pid;

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!