Reputation: 447
i have a query that return a single codeNumber i want to use that code to as a where condtion in another query to return the name field
this is the query
select e1.SuperCODE
from (select EE.* from Table1 e , Table2 ee
where ee.CODE=e.CODE
and ee.TYPE_CODE=13
and E.ID=2089
order by E.FROM_DATE) e1
where rownum = 1;
the result from this query 490
i want to take this result to put it in this query
select name from Table2 (the same table above)
where Table2.code= THE RESULT FROM ABOVE QUERY //490
Upvotes: 1
Views: 2620
Reputation: 1269873
Did you try just using =
with a subquery:
select t2.*
from table2 t2
where t2.code = (select e1.SuperCODE
from (select ee.*
from Table1 e join
Table2 ee
on ee.CODE = e.CODE
where ee.TYPE_CODE = 13 and
e.ID = 2089
order by e.FROM_DATE
) e1
where rownum = 1
);
Note the use of proper, explicit JOIN
syntax.
Upvotes: 1