简体   繁体   English

使用 Eloquent 时字段列表中的列“id”不明确

[英]Column 'id' in field list is ambiguous using Eloquent

Does anyone know why the following is resulting in a Column 'id' in field list is ambiguous error?有谁知道为什么以下会导致字段列表中的列“id”是不明确的错误?

$app_subj_current = \DB::table('tbl_subject')
        ->join('tbl_application', 'tbl_subject.id', '=', 'tbl_application.app_subj_id')
        ->where('tbl_application.id', $application)
        ->lists('tbl_subject.subj_type', 'tbl_subject.id');

I've specified the table for which ID I'm referring to so I cannot understand why I'm getting this error.我已经指定了我所指的 ID 的表,所以我不明白为什么我会收到这个错误。

I've figured out that the following fixes the problem:我发现以下解决了这个问题:

$app_subj_current = \DB::table('tbl_subject')
    ->join('tbl_application', 'tbl_subject.id', '=', 'tbl_application.app_subj_id')
    ->where('tbl_application.id', $application)
    ->select('tbl_subject.subj_type as x', 'tbl_subject.id as y')
    ->lists('x', 'y');

use select() instead of lists() .使用select()而不是lists() hope it work.希望它起作用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM