I´m trying to create a nested-sql that is suposed to show me all ID
from table1
that also is in table2
, but the thing is that if the row from table1
got the flag istask = 1
i want it to select the parentid
instead of the ID
.
There can be multiple ID
with the same parentid
I know that this is simply done by a join but in IBM Maximo´s webinterface you are not alowed to create joins in a query and we can not create views that can be accessed within Maximo´s webinterface
I have tested with the following queries but i will only get the missing right parenthesis error.
If i try the queries as own queries they work.
Test 1
SELECT * from table1
WHERE id in(SELECT refid from table2 WHERE table1.istask = 0
OR (SELECT DISTINCT table1.parentid from table1 WHERE
id in(select refid from table2 WHERE table1.istask = 1)))
Test 2
SELECT * from table1
WHERE id in((SELECT refid from table2 WHERE table1.istask = 0 )
OR (SELECT DISTINCT table1.parentid from table1 WHERE
id in(select refid from table2 WHERE table1.istask = 1))))