搜尋

首頁  >  問答  >  主體

多表聯合查詢問題

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

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

問題出來了,

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

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

每個name出現的總次數 

nearestnearest2665 天前1334

全部回覆(1)我來回復

  • 路过

    路过2017-10-25 08:44:58

    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;

    回覆
    0
  • 取消回覆