Level 102
This is wrong. WhereColumn compares columns
->whereColumn('course_interests.user_id', Auth::id());
//should be
>where('course_interests.user_id', Auth::id());
2 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi guys , my code didn't work can you correct it should be select * from courses where course_id doesn't exists in batches and course_interest table.
$courses = DB::table('courses')
->whereNotExists(function ($query) {
$query->select('course_id')
->from('batches')
->whereColumn('batches.course_id', 'courses.id');
})
->whereNotExists(function ($query) {
$query->select('course_id')
->from('course_interests')
->whereColumn('course_interests.user_id', Auth::id());
})
->get();
This is wrong. WhereColumn compares columns
->whereColumn('course_interests.user_id', Auth::id());
//should be
>where('course_interests.user_id', Auth::id());
Please or to participate in this conversation.