Make a JOIN of two separated DQLs

2k Views Asked by At

Because of a limitiation on the platform, we couldn't make a sub-select of one select. This is our DQL:

   SELECT attr_nombre FROM lis_mindo_abogados WHERE attr_codigo_usuario in (Select attr_abogadoppal_code FROM me_mindo_mail where r_object_id='@r_object_id')

So, we planned to make a JOIN of this two separated DQLs:

   SELECT attr_abogadoppal_code, r_object_id FROM me_mindo_mail WHERE r_object_id='@r_object_id'

   SELECT attr_nombre FROM lis_mindo_abogados WHERE attr_codigo_usuario in ('CODE_ABOGADO1','CODE_ABOGADO2','CODE_ABOGADO3')

For one r_object_id, we have several attr_abogadoppal_code (CODE_ABOGADO1/2/3).

Does it possible to make any kind of JOIN of this two separated DQLs?

Thanks for your time and help!

2

There are 2 best solutions below

9
On

May be so:

SELECT l.attr_nombre
FROM lis_mindo_abogados l, me_mindo_mail m
WHERE l.attr_codigo_usuario = m.attr_abogadoppal_code
AND m.r_object_id='@r_object_id'
0
On

Since attr_abogadoppal_code is repeating (error messages say so), it needs the ANY keyword :

SELECT l.attr_nombre
FROM lis_mindo_abogados l, me_mindo_mail m
WHERE l.attr_codigo_usuario = ANY m.attr_abogadoppal_code
AND m.r_object_id='@r_object_id'