-2

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)

Dijo
  • 73
  • 2
  • 10

1 Answers1

1

try this

$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();
Ehsan Ilahi
  • 298
  • 5
  • 15