I am working on yii2
. I am using active record for searching a reference number. The query is below
$q = isset($_GET['q']) ? $_GET['q'] : '';
if(empty($q)) exit;
$ser = Survey::find()->where("ref_no like '%$q%'")->andWhere(['status'=>1])->asArray()->all();
return json_encode($ser);
The above query will get all the reference numbers which are in survey table. Now I want to add a NOT IN
condition. The raw query is below
...... where ref_no LIKE '%$q%' NOT IN (select ref_no from installations where ref_no LIKE '%q%')
How can I add this to my active record query?
Any help would be highly appreciated.