Join Tables And Sort Them

How do we join two tables and sort them comparing two columns (compare one column from table1 and another column from table 2) using Criteria which is an Active Record Model…

i have my code like the below…

$Criteria = new CDbCriteria();

$Criteria->join=‘LEFT JOIN abc_tablename ON some_id=one_id’;

$Criteria->order = "created_date DESC,commented_date DESC";

it looks like a working code, but the table is not specified.

try like this

t1.coloumn1 DESC, coloumn2 ASC

print_r($Criteria); will give u good idea.

and one more thing, in the join condition u r also not specified the table




'join' => 'JOIN business_profile ON profile_id = business_profile.id' //note business_profile.id 



thank u ranjith,

i finally solved the problem by implementing like this,

$Criteria = new CDbCriteria();

	$Criteria->join='LEFT JOIN pv_comments AS pc ON t.blog_id=pc.goal_id';


	$Criteria->order = " CASE WHEN pc.commented_date IS NULL THEN t.created_date


						  WHEN pc.commented_date IS NOT NULL THEN pc.commented_date


		    ELSE 1


		    END DESC";