show the joined tables

If I joind tables as below

SELECT full_table.ID, cont_table.Additional_info

FROM full_table

LEFT JOIN join_contact ON full_table.ID = join_contact.full_id

LEFT JOIN cont_table ON join_contact.cont_id = cont_table.c_id

the result will be

ID-----------Aditional info

1 hello

1 hi

it repeats records I want the result to be

ID--------------Additional info Additional info

1 hello hi

I wrote the previous sql statement to be clear to understand but the code witch I used in yii is :




<?php

$this->breadcrumbs=array(

	'Notification Tables'=>array('index'),

	$model->ID,

);


$this->menu=array(

	array('label'=>'List FullTable', 'url'=>array('index')),

	array('label'=>'Create FullTable', 'url'=>array('create')),

	array('label'=>'Update FullTable', 'url'=>array('update', 'id'=>$model->ID)),

	array('label'=>'Delete FullTable', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->ID),'confirm'=>'Are you sure you want to delete this item?')),

	array('label'=>'Manage FullTable', 'url'=>array('admin')),

);


?>


<h1>View Table #<?php echo $model->ID; ?></h1>


<?php

$dt2 = new CActiveDataProvider ('JoinContact', array ( 

    'criteria' => array ( 

        'with'=>array('cont','full'),

    'select'=>"full_id",

      'condition' => 'full_id=:full_id', 'params'=>array(':full_id'=>$model->ID),

        

     


    ) ,

    'pagination' => array ( 

        'PageSize' => 20, 




    )));


//$model2=new T2;

echo '<br/>';echo '<br/>';echo '<br/>';echo '<br/>';

$this->widget('zii.widgets.grid.CGridView', array(

    'dataProvider' =>$dt2,   // provided by the controller


    'columns' => array(

         

                'full.ID',

		'full.Province',

		'full.Site_Name',

		'full.Site_ID',

		'full.Servity',

        

		'full.Generated_Time',

		'full.Clear_Time',

		'full.Sms_Notify_Time',

		'full.Cause',

		'full.Action',

		'full.direction',

		'full.Omc_Person',

        'cont.Contacted_Person',

        'cont.Additional_info',

   

    // 'T1_id',

     // 'T1_addid',

        

 )));



Please do not post the same question to multiple sub-forum I deleted the other one in "tips, snipets and tutorials" as that forum is for tips not for questions

As for your problem… I don’t think there is a way to get what you want automaticaly with one select… as you would like to group on one field but get all the values from different rows as the second grouped field…

only way to do this is manually from what I know…

You can try use GROUP_CONCAT function in MySQL. For example:

SELECT full_table.ID, GROUP_CONCAT(cont_table.Additional_info SEPARATOR ’ ') as Additional_info

FROM full_table

LEFT JOIN join_contact ON full_table.ID = join_contact.full_id

LEFT JOIN cont_table ON join_contact.cont_id = cont_table.c_id

group by full_table.ID