Column ’emp_id’ in IN/ALL/ANY subquery is ambiguous

By | November 17, 2016

Below query execution throwing the error Column ’emp_id’ in IN/ALL/ANY subquery is ambiguous

select employees.emp_id,emp_reg_date from employees
join emp_linking_table on emp_linking_table.emp_id=employees.emp_id

where emp_id not in( select emp_id from data_record_table)

solution: if you change condition like as below will give proper result

where employees.emp_id not in( select emp_id from data_record_table)