how to use this sql in yii

i can’t figure out the way to convert this sql into the yii friendly CDbCriteria?




    select * from

      (select media_id from usermedia as records where album_id = 13) 

      records,media

      where 

      media.id = records.media_id






 $criteria = new CDbCriteria;

       $criteria->condition = 't.id IN(select media_id from usermedia where album_id='.$id.')';



done it and its working fine. but is it good approach or a better solution exists ?

i think you need to reconstruct your sql




select * from media

inner join usermedia on media.id = usermedia.media_id

where usermedia.album_id = 13