'How to Laravel Mysql fetch data from database using multiple table join
This is my data retrieving query:
$admin_students=DB::select("select students.*,application_record.*,gender_record.*,
application_record.id as app_primary_id,application_record.status as app_status from students
left join application_record on application_record.student_id=students.id
left join application_record on application_record.gender_record_id=gender_record.name");
Table structure
Table 1 = application_record - > id, name, status, gender_record_id, ....
Table 2 = gender_record - > id, name
Now how can I return the Gender Name using the Gender Record ID which is the primary key for "Table 2"?
Solution 1:[1]
DB:: table('students')
->leftjoin('application_record, 'students.id','=' , 'application_record.student_id' )
->leftjoin('gender_record','application_record.gender_record_id','=','gender_record.id')->select('students.*',' application_record.*,
'gender_record.*,)->get();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dip Ghosh |
