2017-11-11 10 views
0

我有兩個表的Tbl_payroll_leave_employeev2tbl_payroll_leave_schedulev2,我想join他們,但即時得到類似這樣的錯誤完整性約束違規:1052列和where子句是曖昧

「SQLSTATE [23000]:完整性約束違規:1052列 'payroll_leave_employee_id' 在where子句是不明確的(SQL:選擇payroll_employee_idtbl_payroll_leave_employee_v2內上tbl_payroll_leave_employee_v2加入tbl_payroll_leave_schedulev2payroll_leave_employee_id = tbl_payroll_leave_schedulev2payroll_leave_employee_id其中payroll_leave_employee_id = 5。)◀」

我的表結構 enter image description here

$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(); 

回答

1

在情況下,你必須定義表tbl_payroll_leave_employee_v2或表的字段payroll_leave_employee_idtbl_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();

+0

謝謝:)先生 – nethkennnnn

相關問題