扫码关注官方订阅号
【star明星表】id name 有N多明星,自增id【sing歌曲表】id name star_idN多歌曲【movie电影表】id name star_idN多电影
查询每个明星一共有多少歌曲多少电影name cout_sing count_movie
闭关修行中......
select conut(tb1.id) as singnumfrom star as tb3left join sing as tb1 on tb1.starid=tb3.idwhere tb3.id=somenoe
select a.name,count(b.id) as singnum,count(c.id) as movienum from star as aleft 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.
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
select conut(tb1.id) as singnum
from star as tb3
left join sing as tb1 on tb1.starid=tb3.id
where tb3.id=somenoe
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.