select distinct mlj.emp_id,mlj.name, concat_ws(' - ',main_reason, sub_reason) as
reason_for_leaving, comments_of_exit_interviewer, interviewer_name
from my_exit
left join
(select a.emp_id, concat_ws(' ',name,surname) as name, function,
ref_grade, reportingto, main_function, DESIGNATION, region,
date_format (submitted_on, '%d-%b-%Y') as dor
from employee a, my_exit b
where a.emp_id = b.emp_id
and BASE_LOCATION in ('Bangalore','Bangalore Corporate Office',
'SA Beijing','SA Singapore','SA Sydney')) as mlj
on mlj.emp_id = my_exit.emp_id
left join
(select reporting_manager_empid,
round( abs( datediff(date_of_join, last_working_day))/360,2)
as work_exp, date_format(last_working_day,'%d-%b-%Y') as lwd,
typeexit, a.emp_id
from employee a, resignationForm b
where a.emp_id = b.emp_id
and BASE_LOCATION in ('Bangalore', 'Bangalore Corporate Office',
'SA Beijing','SA Singapore','SA Sydney')) as rlj
on my_exit.emp_id = rlj.emp_id
left join
(select a.emp_id, q33, comments_of_exit_interviewer, interviewer_name
from my_exit a, ext_intererview_ans b
where a.emp_id = b.emp_id) as slr
on my_exit.emp_id = slr.emp_id
and slr.emp_id is not null
where mlj.name is not null
left join immcf on resignationForm.emp_id = immcf.emp_id
where immcf.submittedby is null and date(submitted_on)>='2018-01-01'
order by date(submitted_on);
查询失败并出现一些问题。
错误1064(42000):您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在resignationForm.emp_id = immcf.emp_id'上使用“左边连接immcf”附近的正确语法。在第1行
答案 0 :(得分:1)
您有多个WHERE
子句,这是不允许的。并且WHERE
子句必须在所有JOIN
和FROM
子句之后编写。您的订单为WHERE
,LEFT JOIN
,WHERE
。
答案 1 :(得分:0)
你在Where子句之后做左联接。 首先,您需要编写所有连接,然后编写Where子句。
"....where mlj.name is not null left join immcf on resi...."