Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Bilalfarhat24's avatar

Getting Data from multiple tables

I have three tables persondetail, fatherdetail and Marks. I want to get the columns from each table and show them in a view. I want to show persondetail_id, firstname from persondetail, f_firstname from father details and I%age from Inter Marks in a single view. How can i do this?

PersonDetail

Schema::create('persondetail',function(Blueprint $table){
             $table->increments('persondetail_id');
             $table->integer('user_id')->unsigned();
             $table->string('firstname');
             $table->string('middlename');
             $table->string('lastname');
             $table->string('day');
             $table->string('month');
             $table->string('year');
             $table->string('birthplace');
             $table->string('city');
             $table->string('cnic');
             $table->string('gender');
             $table->nullableTimestamps();
});
    Schema::table('persondetail', function($table) {
       $table->foreign('user_id')->references('fatherdetail_id')->on('fatherdetail');
   }); 

FatherDetail

Schema::create('fatherdetail',function(Blueprint $table){
             $table->increments('fatherdetail_id');
             $table->string('f_firstname');
             $table->string('f_middlename');
             $table->string('f_lastname');
             $table->string('f_status');
             $table->string('g_firstname');
             $table->string('g_middlename');
             $table->string('g_lastname');
              $table->nullableTimestamps();
        });

Marks

Schema::create('inter',function(Blueprint $table){
             $table->increments('inter_id');
             $table->string('I_year');
             $table->string('I_Marks');
             $table->string('I_Obtained');
             $table->string('I_college');
             $table->string('I_%age');
             $table->string('I_gpa');
             $table->string('I_subjects');
             $table->nullableTimestamps();
        });
1 like
1 reply

Please or to participate in this conversation.