php - Joining the parent table to its child and get the data from it -



php - Joining the parent table to its child and get the data from it -

i have 2 database. parentsub , childsub

parentsub

|id|component_name|weight|actualweight 1 0 0 2 b 0 0 3 c 0 0 4 d 0 0 5 e 0 0 6 f 0 0

childsub

|parent_id|category_name|weight|actualweight 1 aa 0 0 2 aaa 0 0 3 aaaa 0 0 4 bb 0 0 5 bbb 0 0 6 cc 0 0 7 ccc 0 0 8 dd 0 0 9 ee 0 0 10 ff 0 0

as can see above childsub have column called parent_id in situation. want column called component_name , after childs info must under in parentsub. this. how can childsub under specific column. a must under parent a. using id.

aa aaa aaaa b bb bbb c cc ccc d dd e ee f ff

i've been using laravel framework. thing i've done component_name column , category_name

getcolumncontroller.php

homecoming view::make('view.index')->with('parentsubs',parentsub::get())->with('childsubs',childsubs::get());

view

<table class="table datatable_simple"> <tbody> @foreach($parentsubs $parentsub) <tr> <td><em>{{{$parentsub->component_name}}}</em></td> </tr> @endforeach </tbody> <tbody> @foreach($childsubs $childsub) <tr> <td>{{{$childsub->survey_question}}}</td> </tr> @endforeach </tbody> </table>

try below:

select (select b.component_name parentsub b b.id = a.parent_id) component_name ,a.category_name,a.weight,a.actualweight childsub

php mysql laravel

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -