--try: select count( distinct a.id ) from OrderProductItem a ,a t where (a.stauts= 2 and a.orgId= 10000 ) or (a.id=t.parentid and t.stauts= 0 and t.stauts_deliver= 22 )
select count( distinct a.id ) from OrderProductItem a where ( a.stauts= 2 and a.orgId= 10000 ) or (a.id in ( select a.parentid from a where a.stauts= 0 and a.stauts_deliver= 22 ))
select count(distinct id) from ( select id from OrderProductItem where stauts= 2 and orgId= 10000 union all select a.id from OrderProductItem a join OrderProductItem b on a.id=b.parentid where b.stauts=0 and b.stauts_deliver= 22 ) t
select count( distinct a.id ) from OrderProductItem a where ( a.stauts= 2 and a.orgId= 10000 ) or (a.id in (select a.parentid from a where a.stauts= 0 and a.stauts_deliver= 22 group by a.parentid )) in这个相当再查询一遍
select a.parentid from a where a.stauts= 0 and a.stauts_deliver= 22
))
from
(
select id from OrderProductItem where stauts= 2 and orgId= 10000
union all
select a.id
from OrderProductItem a join OrderProductItem b
on a.id=b.parentid
where b.stauts=0 and b.stauts_deliver= 22
) t
in这个相当再查询一遍