SELECT student_subjects.student_id,student_subjects.subject_id,student_subjects.amount FROM student_subjects NOT NOT EXISTS(来自payment_history的subject subject_id,其中student_subjects.subject_id = payment_history.subject_id)
答案 0 :(得分:1)
试试这个
$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();