我们如何在yii
中为此查询实现CActive RecordSELECT *
FROM location WHERE locationid NOT IN
( SELECT location
FROM memberlocation
WHERE memberid = 2371)
答案 0 :(得分:3)
试试这个
$sql='SELECT *
FROM location WHERE locationid NOT IN
( SELECT location
FROM memberlocation
WHERE memberid = 2371)';
$result = Yii::app()->db->createCommand($sql)->queryAll();
或者你可以做这样的事情
$result= Location::model()->findAll(array(
'select'=>'*',
'condition'=>'locationid NOT IN( SELECT location
FROM memberlocation
WHERE memberid = :member_id)',
'params'=>array(':member_id'=2371)
));