How to sort by related attribute?

I have 2 sql tables,

Products, Products_Descriptions

Products_Descriptions has "id, prodId, name, desc, langId"

I want to sort by "name".

Here is my controller code…

$dataProvider=new CActiveDataProvider('Products', array(


		'select' => 'imageId, id, price, wholesale_price',



				'select' => 'name',





	'sort' => array(

		'defaultOrder' => 'date DESC',

		'separators' => array(




		'attributes' => array(

			'name' => array(

				'asc' => ' ASC',

				'desc' => ' DESC',

				'label' => 'qwe',






$this->render('list', array(

	'dataProvider' => $dataProvider,


and here is my view code

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



	'ajaxUpdate' => false,








but when i hit the "Name" sort. Error occured.

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘’ in ‘order clause’. The SQL statement executed was: SELECT t.imageId AS t0_c1, AS t0_c0, t.price AS t0_c4, t.wholesale_price AS t0_c5 FROM prod_sub1_products t ORDER BY ASC LIMIT 10

i really want to know how to sort by related attribute

query in error message shows that there is no join with the other table… what is the relation type of ‘descriptions’? probably HAS_MANY? if so - try to add ‘together’=>true to ‘with’=>array( ‘descriptions’=>array( [here] ) ) so Yii will join tables in one query instead of merge objects from two separate queries

its great, thank you