然后我加入它:
SELECT CONCAT(ee.first_name,' ',ee.last_name) as valuated_name,CONCAT(ee.first_name,' ',ee.last_name) as valuator_name from emp_employee as ee
left join perf_component_valuation as pcv on pcv.valuator=ee.employee_id
WHERE pcv.phc_id =49;
试试这个:
SELECT CONCAT(ee.first_name,' ',ee.last_name) as valuated_name,CONCAT(ee.first_name,' ',ee.last_name) as valuator_name from emp_employee as ee
left join perf_component_valuation pcv on pcv.valuator=ee.employee_id
left join perf_component_valuation pcv2 on pcv2.valuated=ee.employee_id
WHERE pcv.phc_id =49;
但它只给我一个估价师名称,而不是估价。这是结果:
我想要的结果是:
valuated_name || valuator_name
______________________________
Adni || Arli Ramdhani
Adni || Mohammad Aldo
我怎样才能给出另一个条件?
答案 0 :(得分:1)
尝试两次加入emp_employee
SELECT CONCAT(valuated_ee.first_name,' ',valuated_ee.last_name) as valuated_name,CONCAT(valuator_ee.first_name,' ',valuator_ee.last_name) as valuator_name
from perf_component_valuation as pcv
left join emp_employee as valuated_ee on pcv.valuated=valuated_ee.employee_id
left join emp_employee as valuator_ee on pcv.valuator=valuator_ee.employee_id
WHERE pcv.phc_id =49;
答案 1 :(得分:0)
你使用了一个相同的别名ee
,试试这个;)
SELECT CONCAT(pcv.first_name,' ',pcv.last_name) as valuated_name,CONCAT(ee.first_name,' ',ee.last_name) as valuator_name from emp_employee as ee
left join perf_component_valuation as pcv on pcv.valuator=ee.employee_id
WHERE pcv.phc_id =49;