KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Combine two columns from different tables #382

Open sneha narnaware opened this topic on on Jul 20, 2018 - 6 comments

sneha narnaware commented on Jul 20, 2018

Hi ,

I am trying to combine two column from different table....

i have two tables ...table1 contain date filed and table2 also contain date column wants to combine both table if date is match its add matching record if date doesn't match its insert unmatched date two first table date column and add records ...

please help with this....

KoolReport commented on Jul 20, 2018

You may join two table into one with join process

sneha narnaware commented on Jul 20, 2018

Thanks for your response ... I tried with join but its gives only matching records and......i want unmatched records also ..

KoolReport commented on Jul 20, 2018

So what do you want to do with the unmatched rows ( rows from table1 and rows from table 2)

sneha narnaware commented on Jul 20, 2018

here are two diff table need to combine and like expected table showed in above ... trying to combine with created date column from table1 and generated_date from table 2 .... yellow color are unmatched and blue is matched ....

by this table i have put into the line chart ..... I appreciate your help .....

KoolReport commented on Jul 20, 2018

I think it requires a full join table which is not available now, may be in the next version. However, for now you can do it by yourself. You can get raw data from two dataStore(), process your own join. Then later input the resulted array into Table widget's dataSource to display:

$table1 = $this->dataStore("table1")->data();
$table2 = $this->dataStore("table2")->data();

//Do process here to join two array $table1 and $table2 into 1 array which is your final table

Later you can display the $table like this:

<?php
Table::create(array(
    "dataSource"=>$final_table
));
?>
sneha narnaware commented on Jul 20, 2018

Thanks for response ... i tried as you suggested ...

$table1 = $this->dataStore("table1")->data(); $table2 = $this->dataStore("table2")->data();

$final_table=array_merge($table1, $table2); $final_table ->pipe($this->dataStore("final_table")); <?php

	Table::create(array(
        "dataStore"=>$this->dataStore('final_table'),  
		"width"=>"80%",
      
"cssClass"=>array(
    "table"=>"table table-hover table-bordered"
),
    ));
    ?>

its throws an error ...

Call to a member function pipe() on a non-object [file] =>

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None