简体   繁体   English

违反完整性约束:1052列和where子句不明确

[英]Integrity constraint violation: 1052 Column and in where clause is ambiguous

I have two table the Tbl_payroll_leave_employeev2 and tbl_payroll_leave_schedulev2 and i want to join them but im getting an error like this 我有两个表Tbl_payroll_leave_employeev2tbl_payroll_leave_schedulev2 ,我想join他们,但我收到这样的错误

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) ◀ SQLSTATE [23000]:完整性约束违规:1052列在where子句是不明确的'payroll_leave_employee_id'(SQL:选择payroll_employee_idtbl_payroll_leave_employee_v2内部联接tbl_payroll_leave_schedulev2tbl_payroll_leave_employee_v2payroll_leave_employee_id = tbl_payroll_leave_schedulev2payroll_leave_employee_id其中payroll_leave_employee_id = 5)◀

My table structure 我的表结构 在此处输入图片说明

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

In where condition, you must define the field payroll_leave_employee_id of table tbl_payroll_leave_employee_v2 or table tbl_payroll_leave_schedulev2 在情况下,你必须定义字段payroll_leave_employee_idtbl_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();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 完整性约束违规:1052 where子句中的列'id'不明确 - Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous 违反完整性约束:1052 order子句中的“位置”列不明确 - Integrity constraint violation: 1052 Column 'position' in order clause is ambiguous SQLSTATE [23000]:违反完整性约束:1052 where 子句中的列“值”不明确 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'value' in where clause is ambiguous Laravel Eloquent SQLSTATE[23000]:违反完整性约束:1052 列...在 where 子句中不明确 - Laravel Eloquent SQLSTATE[23000]: Integrity constraint violation: 1052 Column ... in where clause is ambiguous Magento问题与外部mod“违反完整性约束:1052 where子句不明确的列'created_at'” - Magento issue with external mod “Integrity constraint violation: 1052 Column 'created_at' in where clause is ambiguous” Laravel 6 错误:SQLSTATE[23000]:违反完整性约束:1052 where 子句中的列“id_perusahaan”不明确 - Laravel 6 Error : SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id_perusahaan' in where clause is ambiguous SQLSTATE [23000]:完整性约束违规:1052 where子句中的列'NRP'不明确 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'NRP' in where clause is ambiguous 完整性约束违规:1052 列 'group_id' 在 where 子句不明确 - Integrity constraint violation: 1052 Column 'group_id' in where clause is ambiguous SQLSTATE[23000]:违反完整性约束:1052 列 'created_at' 在 where 子句中不明确 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in where clause is ambiguous SQLSTATE [23000]:完整性约束违规:1052 order order中的'created_at'列不明确Laravel 5.5 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in order clause is ambiguous Laravel 5.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM