我对dbms的行为和我的查询相当困惑,这就是为什么我需要一些帮助。
我有3个不同的表:
T1 org_info (routing , job_id)
VALUES ('|1111|2222|','1300');
T2 aff_info (job_id , employee_id , dbegin)
VALUES('1300','0153','10/02/2017');
T3 pers_info (employee_id , name)
VALUES('0153','Gates');
post\u info表保存了关于谁在工作的所有记录,因此我的查询的目的是获取最近在这个工作上的人。
我的问题是:
SELECT distinct a.employee_id AS Mat,
o.routing AS Routing,
o.job_id AS Job,
p.last_name AS Name,
a.job_id AS Job2,
a.dbegin AS Date_begin
FROM org_info o
INNER JOIN aff_info a
ON o.job_id = a.job_id
INNER JOIN(
SELECT MAX(dbegin_post) AS dmax, job_id
FROM aff_info
GROUP BY job_id) b
ON a.job_id = b.job_id
INNER JOIN pers_info p
ON a.employee_id = p.employee_id
WHERE a.dbegin = dmax
AND o.routing LIKE '%2222%'
AND a.job_id= 1300 <!-- Works only with this parameter-->
如果我删除最后一个参数,它将崩溃并出现以下错误:
查询执行被中断
我希望能解释清楚这一次:)
谢谢
暂无答案!
目前还没有任何答案,快来回答吧!