我已使用以下mysql查询:
select q.question,q.formnumber,g.forename,a.guardiancode from tblfeedbackquestions q
join tblfeedbackanswers a on q.id=a.questionid join tblguardian g on g.guardiancode=a.guardiancode where q.formnumber='3'
该查询的输出是:
现在我想要的只是同一个监护人代码的第一行应该出现在第1行和第2行的输出中,我的监护人代码为10025,但是我只希望第一行,并且每个唯一的监护人代码都类似。
尝试添加GROUP BY
:
select q.question,q.formnumber,g.forename,a.guardiancode
from tblfeedbackquestions q
join tblfeedbackanswers a on q.id=a.questionid join tblguardian g
on g.guardiancode=a.guardiancode
where q.formnumber='3'
GROUP BY g.guardiancode
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句