如何将下面的 sql 查询转换为 yii2 代码
How to convert below sql query into yii2 code
SELECT student_subjects.student_id,student_subjects.subject_id,student_subjects.amount FROM student_subjects where NOT EXISTS(SELECT subject_id from payment_history 其中 student_subjects.subject_id=payment_history.subject_id)
试试这个
$sql="SELECT student_subjects.student_id,student_subjects.subject_id,student_subjects.amount FROM student_subjects where NOT EXISTS(SELECT subject_id from payment_history where student_subjects.subject_id=payment_history.subject_id)"
Yii::app()->db->createCommand($sql)->queryAll();
SELECT student_subjects.student_id,student_subjects.subject_id,student_subjects.amount FROM student_subjects where NOT EXISTS(SELECT subject_id from payment_history 其中 student_subjects.subject_id=payment_history.subject_id)
试试这个
$sql="SELECT student_subjects.student_id,student_subjects.subject_id,student_subjects.amount FROM student_subjects where NOT EXISTS(SELECT subject_id from payment_history where student_subjects.subject_id=payment_history.subject_id)"
Yii::app()->db->createCommand($sql)->queryAll();