Category : inner-join

$users = DB::table(‘users’) ->join(‘course’, ‘users.id’, ‘=’, ‘course.courseId’) ->join(‘skills’, ‘users.id’, ‘=’, ‘skills.id’) ->join(‘subjects’, ‘users.id’, ‘=’, ‘subjects.id’) ->get(); dd($users); This gives me an empty result like this- items: []. I would like to join the 4 tables – users, course, skills & subjects and fetch all the datas in all the 4 tables. users table has the ..

Read more

I am trying to execute the following code, the error applies to the $waitingToBeShipped… section of the code. As you can see I am using an innerJoin. I want to retrieve all of the rows that have orders containing products that are still waiting to be shipped. public function destroyMany($ids) { $status = false; $ids ..

Read more

How can I get the category names for a given subject whose my case is chemistry? This is the subject.blade.php code subject.blade.php code This is my subject table subjects table This is my category table categories table This is the web view of the result Subject.blade.php web view Sourc..

Read more

my database tables One is Categories with (Id, name) 2nd is Blog with (id, post, img) 3rd is Blog_category with (id, blog_id, category_id) query I’m using $blogs = Blog::join(‘categories’, ‘blog_categories.category_id’, ‘=’, ‘categories.id’)->orderBy(‘created_at’, ‘DESC’)->get(); return response()->json($blogs, 200); error I’m getting SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘blog_categories.category_id’ in ‘on clause’ (SQL: select * from blogs ..

Read more

Here i want to get all the maximum date values from all the rows depending on the report_type_id so in order to get that i wrote my query like this $latest_reports = Filelist::select(DB::raw(‘s1.*’)) ->from(‘filelists as s1’) ->where(‘s1.access_id’,’=’,$retailer_supplier_id->id) ->join(DB::raw(‘(SELECT id,report_type_id,access_id,MAX(data_date) AS data_date FROM filelists GROUP BY report_type_id) as s2’), function($query) use ($retailer_supplier_id) { $query->on(‘s1.report_type_id’, ‘=’, ‘s2.report_type_id’) ..

Read more

In db one filed is varbit the other field int4. So I am trying to do cast with inner join in Laravel. But it isnt work ->join(‘be_product’,’be_product.id’,’=’, ‘DB::raw(‘CAST(‘be_medical_insurance_for_foreigners.product_id’ AS INT’))’) ->where(‘id’,’=’,$id) How can i resolve this problem ? Sourc..

Read more

<?php namespace AppHttpControllers; use IlluminateHttpRequest; use IlluminateSupportFacadesDB; class universityController extends Controller { // public function getStudents(Request $req) { $students= DB::table(‘students’) ->join(‘applicants’, function ($join) { $join->on(‘students.id’, ‘=’, ‘applicants.studentid’) ->where(‘applicants.scholarshipid’,’=’, $req->scholarshipid); }) ->get(); return $students; // return $req->scholarshipid; } } Sourc..

Read more