2011-05-06 73 views
2

我有四个查询返回整数。jpql INTERSECT without INTERSECT

select listOfIntegers from [something]... 

编辑:结果行)

,并需要一种方法来做到

select ... 
intersect 
select ... 
intersect 
select ... 
intersect 
select ... 

但JPQL没有相交这样。

那么,有没有办法模仿使用其他jpql获得相同结果的行为?

(对于那些不确定交点)基本上我需要得到所有出现在所有的选择值...

result from select 1: 1,2,3,4 
result from select 2: 1,2,5,6 
result from select 3: 1,2,7,8 
result from select 4: 1,2,9,0 

so the result i want with intersect: 1,2 

日Thnx很多

附:没有机会使用ANYHTING以外的其他JPQL :(没有原生查询,等等

+0

导致的行或列? – 2011-05-06 08:57:01

+0

结果行 – b0x0rz 2011-05-06 09:46:58

回答

2

你可以使用这样的事情?:

select s1.result 
    from select_1 as s1 
where exists (
       select * 
       from select_2 as s2 
       where s2.result = s1.result 
      ) 
     and exists (
        select * 
        from select_3 as s3 
        where s3.result = s1.result 
       ) 
     and exists (
        select * 
        from select_4 as s4 
        where s4.result = s1.result 
       ); 
+1

吃午饭,但会尝试后... – b0x0rz 2011-05-06 10:20:51

+1

对不起,漫长的午餐:P谢谢 - 完美的作品 – b0x0rz 2011-05-06 12:35:53