我需要一条 SQL 语句来从数据库中提取那些同时具有附件标签的申请人。如果我想要具有 7 或 8 作为附件标签的申请人,但我需要同时具有这两个标签的申请人,那么下面的 q 语句可以正常工作。
select distinct(a.id) from applicant a
join applicantdeployment ad on a.id = ad.applicantid
join ApplicantAttachment at on a.id = at.applicantid
where a.applicanttype = 'TCN/LN' and ad.groundlocation in (4,8,14) and ad.deploymentstatus =1
and ad.trainingdeploymentstatus = 6 and at.tag in (7,8)
例如,从下面的集合中,我只想显示 ids 7332,7451 和 7449。
ID 标签
7328 8
7328 8
7332 8
7332 7
7337 7
7449 8
7449 7
7451 8
7453 7
7451 7
谢谢!