select t1.stu_id, t1.class,name, t1.per_check, t1.pen_id, t1.loan_id, t1.sch_id, t1.sti_id, t1.sub_id, (select `check` from zz_penury where id=t1.pen_id ) as pen_check, (select `check` from zz_loan where id=t1.loan_id ) as loan_check, (select `check` from zz_scholarship where id=t1.sch_id ) as sch_check, (select `check` from zz_stipend where id=t1.sti_id ) as sti_check, (select `check` from zz_subsidy where id=t1.sub_id ) as sub_check, t1.id from zz_student as t1 where sub_check=2 order by stu_id desc limit 0,30 这句sql是错的 因为有where sub_check=2 这一句 提示找不到sub_check这一列 select t1.stu_id, t1.class,name, t1.per_check, t1.pen_id, t1.loan_id, t1.sch_id, t1.sti_id, t1.sub_id, (select `check` from zz_penury where id=t1.pen_id ) as pen_check, (select `check` from zz_loan where id=t1.loan_id ) as loan_check, (select `check` from zz_scholarship where id=t1.sch_id ) as sch_check, (select `check` from zz_stipend where id=t1.sti_id ) as sti_check, (select `check` from zz_subsidy where id=t1.sub_id ) as sub_check, t1.id from zz_student as t1 order by stu_id desc limit 0,30 而这样是对的,请问 要如何写 where sub_check=2 这一限制条件
select t1.stu_id, t1.class,name, t1.per_check, t1.pen_id, t1.loan_id, t1.sch_id, t1.sti_id, t1.sub_id, (select `check` from zz_penury where id=t1.pen_id ) as pen_check, (select `check` from zz_loan where id=t1.loan_id ) as loan_check, (select `check` from zz_scholarship where id=t1.sch_id ) as sch_check, (select `check` from zz_stipend where id=t1.sti_id ) as sti_check, (select `check` from zz_subsidy where id=t1.sub_id ) as sub_check, t1.id from zz_student as t1 order by stu_id desc limit 0,30) a
where sub_check=2
where exists (select `check` from zz_subsidy where id=t1.sub_id and `check`=2 )
order by stu_id desc limit 0,30 .
[align=center]==== 思想重于技巧 ====
[/align]
.
贴子分数<20:对自已的问题不予重视。
贴子大量未结:对别人的回答不予尊重。
.
4楼的是效率最高也是我最满意的方法,学到了,谢谢