How can we implement CActive Record for this query in yii
SELECT *
FROM location WHERE locationid NOT IN
( SELECT location
FROM memberlocation
WHERE memberid = 2371)
Try this
$sql='SELECT *
FROM location WHERE locationid NOT IN
( SELECT location
FROM memberlocation
WHERE memberid = 2371)';
$result = Yii::app()->db->createCommand($sql)->queryAll();
Or you could do something like this
$result= Location::model()->findAll(array(
'select'=>'*',
'condition'=>'locationid NOT IN( SELECT location
FROM memberlocation
WHERE memberid = :member_id)',
'params'=>array(':member_id'=2371)
));