I need to generate the following sql query
SELECT `searchjur`.*, `conditions`.* FROM `searchjur` LEFT JOIN `conditions` ON `searchjur`.`id` = `conditions`.`id_event` WHERE `conditions`.`id_jur` = 59 OR NOT EXISTS (SELECT * FROM searchjur WHERE `conditions`.`id_event` = `searchjur`.`id`) In yii2, I do the following
$query = Searchjur::find()->select('searchjur.*, conditions.*'); $query->joinWith(['conditions']); $query->where(['not exists', Searchjur::find() ->where(['`conditions`.`id_event`' => 'searchjur.id'])]); $query->andWhere(['conditions.id_jur' => $id_jur]); return $query->createCommand()->getRawSql() ; The problem occurs with quotes I need at the output
a yii makes 'searchjur.id' single quotes not slashes
Professionals please tell me! Below is the entire query result in yii2.
"SELECT `searchjur`.*, `conditions`.* FROM `searchjur` LEFT JOIN `conditions` ON `searchjur`.`id` = `conditions`.`id_event` WHERE (NOT EXISTS (SELECT * FROM `searchjur` WHERE `conditions`.`id_event`='searchjur.id')) AND (`conditions`.`id_jur`=59)" 