答案 0 :(得分:2)
您可能想看看JOIN的标准MySQL文档
select timeout,
timein,
taggedby.employee_name tagged_by,
untaggedby.employee_name untagged_by
from table_breaktime tb
JOIN table_employee taggedby on taggedby.emp_no = tb.tagged_by
JOIN table_employee untaggedbyon untaggedby.emp_no = tb.untagged_by
我们在表tagged_by
的{{1}}和untagged_by
列上两次加入了employee表。分别获取员工姓名
答案 1 :(得分:1)
这是替代解决方案:
select time_out, time_in,
(select employee_name from table_employee where emp_no = tb.tagged_by) tagged_by,
(select employee_name from table_employee where emp_no = tb.untagged_by) untagged_by,
from table_breaktime tb