我有一个表程序参与者。我目前正在成功查询count(name)> 1.我现在需要查询属于这些ID的名称,其中count(name)> 1。
示例,当前正在返回的数据结果:
- ID count(name)
- 1 2
- 3 4
- 4 3
示例,需要数据结果:
- ID name
- 1 nm1
- 1 nm3
- 3 nm2
- 3 nm3
- 3 nm4
- 3 nm7
- 4 nm5
- 4 nm8
- 4 nm9
解决方法
你可以使用这个:
- SELECT
- (SELECT name FROM participants WHERE id=p.participantid) AS name
- FROM
- programparticipants AS p
- WHERE
- .... (the part where you find count(name)>1)