2017-01-11 71 views
-2

SELECT student_subjects.student_id,student_subjects.subject_id,student_subjects.amount FROM student_subjects其中NOT EXISTS(SELECT從payment_history subject_id其中student_subjects.subject_id = payment_history.subject_id)如何下面的SQL查詢轉換爲yii2代碼

+1

那麼你有什麼嘗試? – Justinas

回答

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(); 
相關問題