我有两个表Tbl_payroll_leave_employeev2
和tbl_payroll_leave_schedulev2
,我想join
他们,但我收到这样的错误
SQLSTATE [23000]:违反完整性约束:1052 where子句中的“ payroll_leave_employee_id”列不明确(SQL:从payroll_employee_id
上的tbl_payroll_leave_employee_v2
内部联接tbl_payroll_leave_schedulev2
中选择tbl_payroll_leave_employee_v2
。payroll_leave_employee_id
= tbl_payroll_leave_schedulev2
。其中payroll_leave_employee_id
= 5)◀
我的表结构
$employee_id = Tbl_payroll_leave_employeev2::select('payroll_employee_id')
->join('tbl_payroll_leave_schedulev2','tbl_payroll_leave_employee_v2.payroll_leave_employee_id','=','tbl_payroll_leave_schedulev2.payroll_leave_employee_id')
->where('payroll_leave_employee_id',$emp)
->get();
最佳答案
在何情况下,必须定义表payroll_leave_employee_id
或表tbl_payroll_leave_employee_v2
的字段tbl_payroll_leave_schedulev2
$employee_id = Tbl_payroll_leave_employeev2::select('payroll_employee_id')
->join('tbl_payroll_leave_schedulev2','tbl_payroll_leave_employee_v2.payroll_leave_employee_id','=','tbl_payroll_leave_schedulev2.payroll_leave_employee_id')
->where('tbl_payroll_leave_schedulev2.payroll_leave_employee_id',$emp)
->get();
关于mysql - 违反完整性约束:1052列和where子句不明确,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47234227/