select pid,count(*) from table1 group by pid;
Find out the total number of occurrences of each pid,
The problem comes out,
Another one The name corresponding to the pid is placed in the table.
Now we need to directly display the number of times each name appears through a joint query.
The total number of occurrences of each name
路过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;