select pid,count(*) from table1 group by pid;
查出每個pid 出現的總次數,
問題出來了,
另一個表裡放了pid對應的name,
現在需要透過聯合查詢,直接顯示出,
每個name出現的總次數
我爱PHP
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;
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;