开发者

jpql INTERSECT without INTERSECT

i have four queries that return intergers.

select listOfIntegers from [something]...

(edit: the results are ROWS)

and need a way to do

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

but in jpql there is no intersect as such.

so, is there a way to mimic the behavior using some other jpql to get the same result?

(for those that are unsure about intersect) basically i need to get all the values that appear in ALL the selects...

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 a lot

p.s. there is no chance to use ANYHTING OTHER THAN JPQL :( no nat开发者_如何学Pythonive queries, etc...


Can you use something like this?:

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
                  );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜