Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从子查询迁移到mysql查询_Mysql_Sql - Fatal编程技术网

从子查询迁移到mysql查询

从子查询迁移到mysql查询,mysql,sql,Mysql,Sql,您好,我有下面的工作查询,但我希望离开子查询方法 select t0.emp_id, t1.first_name, t1.last_name from employee_profile As t0 left join user_profile as t1 on t0.user_profile_id = t1.id where t0.emp_id not in (select t4.emp_id from time_sheet as t4 where t4.ts_end_date = '201

您好,我有下面的工作查询,但我希望离开子查询方法

select t0.emp_id, t1.first_name, t1.last_name

from employee_profile As t0 left join user_profile as t1 on t0.user_profile_id = t1.id

where t0.emp_id not in (select t4.emp_id from time_sheet as t4 where t4.ts_end_date = '2014-10-08')
共有1301份员工档案 有337家没有截止日期2014-10-08的时间表

到目前为止,这是完全可行的

现在,我正在尝试从子查询迁移到联接。我试过下列方法,但没有成功

通过这个查询,我得到了与我所寻找的完全相反的964个结果

select t0.emp_id, t1.first_name, t1.last_name, t3.emp_id

from employee_profile As t0 left join user_profile as t1 on t0.user_profile_id = t1.id 
left join time_sheet as t3 on t0.id = t3.employee_profile_id
我还使用where条件尝试了以下操作,结果为0

一,

二,

有人知道如何解决这个问题吗?

找到了答案

select t0.emp_id, t1.first_name, t1.last_name, t3.emp_id

from employee_profile As t0 left join user_profile as t1 on t0.user_profile_id = t1.id 
left join time_sheet as t3 on t0.id = t3.employee_profile_id and t3.ts_end_date = '2014-10-08'

where t3.employee_profile_id is null
where t3.ts_end_date = '2014-10-08'
and t3.id is null
select t0.emp_id, t1.first_name, t1.last_name, t3.emp_id

from employee_profile As t0 left join user_profile as t1 on t0.user_profile_id = t1.id 
left join time_sheet as t3 on t0.id = t3.employee_profile_id and t3.ts_end_date = '2014-10-08'

where t3.employee_profile_id is null