search

Home  >  Q&A  >  body text

php - mysql3 table query

【star star list】
id name
There are N many stars, self-increase ID
【sing song list】
id name star_id
N many songs
【movie movie Table】
id name star_id
N多电影

Query how many songs and movies each star has in total
name cout_sing count_movie

阿神阿神2733 days ago881

reply all(2)I'll reply

  • 代言

    代言2017-06-30 09:56:49

    select conut(tb1.id) as singnum
    from star as tb3
    left join sing as tb1 on tb1.starid=tb3.id
    where tb3.id=somenoe

    reply
    0
  • 迷茫

    迷茫2017-06-30 09:56:49

    select a.name,count(b.id) as singnum,count(c.id) as movienum
    from star as a
    left join sing as b on a.id=b.star_id left join movie as c on c.star_id=a.id group by b.id,c.id.

    reply
    0
  • Cancelreply