[英]SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'value' in where clause is ambiguous
Im getting this Error:我收到此错误:
(3/3) QueryException
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'value' in where clause is ambiguous (SQL: select * from `users` where exists (select * from `permission_templates` inner join `permissions` on `permission_templates`.`value` = `permissions`.`value` where `users`.`id` = `permissions`.`user_id` and (`value` = TICKET_LIST or `value` = MASTER) and `permission_templates`.`deleted_at` is null) and `id` != 3 and `users`.`deleted_at` is null)
If I run this如果我运行这个
$collaborators = User::whereHas('permissions', function($query) {
$query->where('value', 'TICKET_LIST')
->orWhere('value', 'MASTER');
})->where('id', '!=', Auth::id())
->get();
look like you have a column with name 'value' in your users table.看起来您的用户表中有一个名为“值”的列。
to resolve this, you just have to add table name before column name in where,要解决此问题,您只需在列名之前添加表名,
$collaborators = User::whereHas('permissions', function($query) {
$query->where('permissions.value', 'TICKET_LIST')
->orWhere('permissions.value', 'MASTER');
})->where('id', '!=', Auth::id())
->get();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.