How can I convert this sql into active record query
SELECT * FROM `base_twitter` WHERE id NOT IN (SELECT base_id from base_followers)
Assuming that your models are named BaseTwitter
and BaseFollower
accordingly, this should work:
$subQuery = BaseFollower::find()->select('id');
$query = BaseTwitter::find()->where(['not in', 'id', $subQuery]);
$models = $query->all();