如何连接两个结果集来查询输出来自两个查询?

时间:2016-02-18 11:29:39

标签: mysql php

    $installments = "SELECT
       SUM( installments.t_fee ) AS paid_fee,
       sum(installments.exam_fee) as r_exam,
       sum(installments.lib_fee) as r_lib
    FROM  installments
    JOIN  student ON student.s_id = installments.s_id
    JOIN  program ON program.p_id = student.p_id
    WHERE  installments.paid =1
      AND  installments.curr_sem ='".$q['sem']."'
      AND  student.bat_id ='".$_GET['srch']."'
      AND  installments.s_id='".$q['s_id']."'
      AND  program.p_id='".$_GET['srch1']."'
      AND  student.DeleteStatus=0";

$installments = "SELECT  installments.curr_sem as semester
    FROM  installments
    JOIN  student ON student.s_id = installments.s_id
    JOIN  program ON program.p_id = student.p_id
    WHERE  installments.paid =1
      AND  installments.lib_fee!=0
      AND  student.DeleteStatus=0";

0 个答案:

没有答案