我有5张桌子(我只会谈谈请求中的内容):
这是我的要求:
SELECT Client.email, Client.age, Client.gender
FROM Client,
(SELECT FreqTest.clientEmail
FROM FreqTest,
(SELECT Employee.login
FROM Employee
WHERE Employee.agencyID = 'anID') EmployeeByAgency
WHERE FreqTest.employeeLogin = EmployeeByAgency.login) Freq,
(SELECT QuestTest.clientEmail
FROM QuestTest,
(SELECT Employee.login
FROM Employee
WHERE Employee.agencyID = 'anID') EmployeeByAgency
WHERE QuestTest.employeeLogin = EmployeeByAgency.login) Quest,
(SELECT SitTest.clientEmail
FROM SitTest,
(SELECT Employee.login
FROM Employee
WHERE Employee.agencyID = 'anID') EmployeeByAgency
WHERE SitTest.employeeLogin = EmployeeByAgency.login) Sit
WHERE Client.email = Freq.emailClient
OR Client.email = Quest.emailClient
OR Client.email = Sit.emailClient
GROUP BY Client.email;
我希望在代理商中测试的客户端的电子邮件。 它几乎适用于任何情况,除非没有客户在同一个机构中进行过3次测试。
我不得不尝试用英语翻译,如果我的英语不完美,我很抱歉。
所以要明确(与同一机构):
我想也许是因为如果任何子查询(Freq,Quest或Sit)没有返回任何结果,那么它就是NULL。
如果我不清楚或者我是否错误地翻译了这一切,我想再次道歉。
答案 0 :(得分:0)
使用LEFT JOIN来避免NULL引用
<servlet-mapping>
<servlet-name>socialcare-dispatcher</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>