我有两个问题,第一个问题
SELECT DISTINCT( timesheetemployeeid ) AS USER_ID
FROM timesheet
WHERE timesheetemployeeid != ''
AND ( timesheetemployeeconfirm = 1
OR ( timesheetemployerconfirm = 1
AND ( timesheetdispute = 0
OR timesheetdispute IS NULL ) ) )
AND timesheetemployerremove IS NULL
AND ` timesheetdate ` BETWEEN '2018- 05-27' AND '2018-06-02'
AND office_id = 8
AND timesheetremove IS NULL
AND adminnotconfirmed = 0
AND timesheet_id NOT IN (SELECT parenttimesheet_id
FROM timesheet
WHERE timesheetemployeeid != ''
AND timesheetdate BETWEEN
'2018-05-27' AND '2018-06-02'
AND ( timesheetemployeeconfirm = 1
OR ( timesheetemployerconfirm = 1
AND ( timesheetdispute = 0
OR timesheetdispute IS
NULL )
) )
AND timesheetemployerremove IS NULL
AND timesheetremove IS NULL
AND office_id = 8
AND ( parenttimesheet_id IS NOT NULL
OR parenttimesheet_id != '' ))
UNION ALL
SELECT DISTINCT( employee ) AS Employee
FROM workordercurrent
WHERE employee != ''
AND office_id = '8'
AND schedulestopdate >= '2018-05-27'
AND schedulestopdate <= '2018-06- 02'
收益率
USER_ID
在0.1047秒内完成200次重复
第二个查询返回
Prodpay
在0.2834秒内
SELECT Sum(pay) AS ProdPay
FROM (SELECT currentrate * lineitemquantity AS Pay
FROM (SELECT B.currentworkorder_id,
D.lineitems_lineitemid,
D.lineitemquantity,
C.currentrate,
C.currenteffectivedate
FROM payscaleslocal A
JOIN workordercurrent B
ON A.worktype = B.worktype
AND A.workarea = B.workarea
JOIN payscaleloacljobcodes C
ON A.payscaleslocal_id = C.payscaleslocal_id
JOIN workorderlineitems D
ON C.jobcodeid = D.lineitems_lineitemid
AND
B.currentworkorder_id = D.workordercurrent_workorderid
WHERE A.payscale = '16'
AND B.employee = '1287'
AND B.office_id = '8'
AND B.schedulestopdate = '2018-05-27'
AND ( B.orderstatus = 2
OR B.orderstatus = 3 )
AND C.currenteffectivedate <= '2018-05-27'
ORDER BY C.currenteffectivedate DESC) M
GROUP BY lineitems_lineitemid,
currentworkorder_id) K
我试图使用
IN Clause
So in the second Query - I tried changing the B.Employee IN (<Results of the first query>)
问题是,查询会继续加载,5分钟内不会显示任何结果,我必须关闭phpmyadmin并重新启动它。
我想展示一下
user_id
在第一列中
prodpay
其中
用户标识
在第二列中,通过连接这两个查询