gpt4 book ai didi

mysql - 违反完整性约束 : 1052 Column and in where clause is ambiguous

转载 作者:行者123 更新时间:2023-11-29 06:51:32 24 4
gpt4 key购买 nike

我有两个表,Tbl_payroll_leave_employeev2tbl_payroll_leave_schedulev2,我想加入它们,但我收到这样的错误

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'payroll_leave_employee_id' in where clause is ambiguous (SQL: select payroll_employee_id from tbl_payroll_leave_employee_v2 inner join tbl_payroll_leave_schedulev2 on tbl_payroll_leave_employee_v2.payroll_leave_employee_id = tbl_payroll_leave_schedulev2.payroll_leave_employee_id where 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();

最佳答案

在where条件下,必须定义表tbl_payroll_leave_employee_v2或表tbl_payroll_leave_schedulev2的字段payroll_leave_employee_id

$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 Column and in where clause is ambiguous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47234227/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com