简体   繁体   English

SQLSTATE [23000]:违反完整性约束:1052 where 子句中的列 'id' 不明确

[英]SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous

When I display the name of table using the id of another table in Laravel I declare like this.当我使用 Laravel 中另一个表的 id 显示表的名称时,我这样声明。 But when I want to get the id to edit, the error is like the title.但是当我想编辑 id 时,错误就像标题一样。 Please help me, I am very grateful.请帮助我,我非常感激。

Controller public function manage_departments(){ Controller公共 function manage_departments(){

    $manage_departments=DB::table('departments')
    ->join('faculties','faculties.id','=','departments.faculty_id')
    ->orderBy('departments.created_at','desc')->get();

    $all_manage_departments=view('admin.manage-departments')->with('manage_departments', $manage_departments);

    return view('layouts.master')->with('admin.manage-departments', $all_manage_departments);
}

You don't have select in your query builder.您的查询生成器中没有select As laravel doc said, you can specify what do you want to select in select method.正如laravel 文档所说,您可以在select方法中指定您想要 select 的内容。 I select faculties.id and departments.id for example.我以 select faculties.iddepartments.id .id 为例。

DB::table('departments')
    ->select('faculties.id','departments.id')
    ->join('faculties','faculties.id','=','departments.faculty_id')
    ->orderBy('departments.created_at','desc')->get();

暂无
暂无

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

相关问题 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 子句中的列“值”不明确 - 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 SQLSTATE [23000]:完整性约束违规:1052 where子句中的列'status'不明确 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'status' 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 Laravel 完整性约束违规:1052 列 'id' in where 子句不明确 - Laravel Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous Laravel JOIN SQLSTATE [23000] 问题:违反完整性约束:字段列表中的 1052 列“album_id”不明确 - Laravel JOIN Problem with SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'album_id' in field list is ambiguous 违反完整性约束:1052列和where子句不明确 - Integrity constraint violation: 1052 Column and in where clause is ambiguous 违反完整性约束:1052 where子句不明确的列'prof_id'Laravel - Integrity constraint violation: 1052 Column 'prof_id' in where clause is ambiguous Laravel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM