-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
  • 63
  • 1
  • 8

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
  • 223
  • 3
  • 12