我有四个返回整数的查询。
select listOfIntegers from [something]...
(编辑结果为 ROWS)
需要一种方法来做
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
非常感谢
附注没有机会使用除 JPQL 之外的任何东西 :( 没有 native 查询等...
最佳答案
你能用这样的东西吗?:
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
);
关于sql - jpql INTERSECT 没有 INTERSECT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5908949/