Home > Back-end >  Integrity constraint violation: 1052
Integrity constraint violation: 1052

Time:10-29

Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous (SQL: select * from kumeti_member_registrations left join members list on members list.id = kumeti_member registrations.member_name where id = 2)",

this Query please solve the error

$result = DB::table('kumeti_member_registrations')
            ->leftjoin('members_list', 'members_list.id', '=', 'kumeti_member_registrations.member_name')
            ->where('id', $id)
            ->get();

CodePudding user response:

You need to specify the table name as id is common in both tables and is therefore ambiguous

So

->where('kumeti_member_registrations.id', $id)

CodePudding user response:

Try this:

$result = DB::table('kumeti_member_registrations')
            ->leftjoin('members_list', 'members_list.id', '=', 'kumeti_member_registrations.member_name')
            ->where('kumeti_member_registrations.id', $id)
            ->get();
  • Related