如何按列值计数选择?在SQL查询中,它将是这样的:select * from band inner join bandsinger on band.id = bandsinger.bandid inner join singer on singer.id = bandsinger.singerid group by band.id having count(singerid=6)>0 and count(singerid=4)>0
如果SQLite函数count()
可以接受函数作为参数,但它不接受。
重点是选择两个乐队,其中两个已知身份证的歌手唱歌。
答案 0 :(得分:0)
我找到了解决方案。在这种情况下,查询应为:select * from band inner join bandsinger on band.id = bandsinger.bandid inner join singer on singer.id = bandsinger.singerid where dinger.id = 6 or singer.id=4 group by band.id having count(*)=x
其中x是要计数的给定ID的数量。