jfinal中一个查询的问题
2018-12-25 本文已影响0人
南京确善能
select a.id,a.title,a.timeLimit,a.percentage,a.wbsCode,'unComplate' as status from tb_build_wbs a where a.del=1
and (select count(*) from tb_build_wbs where parentId=a.id)=0
#if(startTime)
and a.startTime>#para(startTime)
#end
#if(endTime)
and a.endTime<#para(endTime)
#end
and percentage<100
union all
select a.id,a.title,a.timeLimit,a.percentage,a.wbsCode,'complate' as status from tb_build_wbs a where a.del=1
and (select count(*) from tb_build_wbs where parentId=a.id)=0
#if(startTime)
and a.startTime>#para(startTime)
#end
#if(endTime)
and a.endTime<#para(endTime)
and a.actualEndTime>#para(endTime)
#end
and percentage=100
很普通的查询,mysql报错
The used SELECT statements have a different number of columns
恶心的是字段全部都对上了,在navicate中查询没有问题!
解决方式
select * from(
select a.id,a.title,a.timeLimit,a.percentage,a.wbsCode,'unComplate' as status from tb_build_wbs a where a.del=1
and (select count(*) from tb_build_wbs where parentId=a.id)=0
#if(startTime)
and a.startTime>#para(startTime)
#end
#if(endTime)
and a.endTime<#para(endTime)
#end
and percentage<100
union all
select a.id,a.title,a.timeLimit,a.percentage,a.wbsCode,'complate' as status from tb_build_wbs a where a.del=1
and (select count(*) from tb_build_wbs where parentId=a.id)=0
#if(startTime)
and a.startTime>#para(startTime)
#end
#if(endTime)
and a.endTime<#para(endTime)
and a.actualEndTime>#para(endTime)
#end
and percentage=100
) as x