search

Home  >  Q&A  >  body text

Multi-table joint query problem

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

nearestnearest2665 days ago1333

reply all(1)I'll reply

  • 路过

    路过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;

    reply
    0
  • Cancelreply