#sql("listForDoctor")
select o.*,b.member_name,b.header,
 (select content from t_qanswers_communication where qanswer_id=o.id ORDER BY id asc limit 1) as first_content
from t_qanswers_order o
 left join t_member b on o.member_id=b.id
 #for(x : cond)
   #(for.index == 0 ? "where": "and")
    #if(x.key=="status")
     o.status in (5,6)
    #else if(x.key=="newStatus")
     (o.status=1 or (o.status=4
 and (select type_code from t_qanswers_communication where  qanswer_id=o.id  ORDER BY id desc limit 1)='MEMBER'
))
    #else if(x.key=="goingStatus")
    o.status=4
 and (select type_code from t_qanswers_communication where  qanswer_id=o.id  ORDER BY id desc limit 1) ='DOCTOR'
    #else
     #(x.key) #para(x.value)
    #end
#end
 order by o.id desc
#end
执行代码如下
select o.*,b.member_name,b.header,
 (select content from t_qanswers_communication where qanswer_id=o.id ORDER BY id asc limit 1) as first_content
from t_qanswers_order o
 left join t_member b on o.member_id=b.id
   where
     o.doctor_id=200207023   and
    o.status=4
 and (select type_code from t_qanswers_communication where  qanswer_id=o.id  ORDER BY id desc limit 1)='DOCTOR'
 order by o.id desc
 
 该条件无效
 (select type_code from t_qanswers_communication where  qanswer_id=o.id  ORDER BY id desc limit 1)='DOCTOR'
 不知道如何解决了,看到的朋友帮忙解答一下
 workbench 下运行结果和项目结果对比

调试获取sql
select o.*,b.member_name,b.header,
(select content from t_qanswers_communication where qanswer_id=o.id ORDER BY id asc limit 1) as first_content
from t_qanswers_order o
left join t_member b on o.member_id=b.id
   where
o.doctor_id=? and
(o.status=4
and (select type_code='DOCTOR' from t_qanswers_communication where qanswer_id=o.id ORDER BY id desc limit 1) =true)
order by o.id desc
参数:
paralist size = 1
value=200207023
 项目:JFinal
 
 
 
 
 
 
 
jfinal 的 arp ,并不会去干涉及 sql 的执行,是直接扔给 jdbc 去执行的