Re:(oracle 8.05) nested select problem
Quote
Glauco Aquino wrote:
> Hi.
> I have got a problem with nested selects in oracle 8.05, but I am refusing
> to believe that is a limitation of the database because is too elementary.
> The problem:
> select
> p.pk_field,
> p.other_field,
> (select c.some_field
> from child_table c
> where c.fk_field = p.pk_field)
> from parent_table p
> when this kind of query is made, an error occurs: "expression missing"
> If there's a problem with oracle 8.05, is there a patch or any other way
> resolve this problem in the database itself?
> Thanks.
Wrong syntax. This is the wrong situtation to use a nested query in any
case - a direct join would be better.
try:
select
p.pk_field,
p.other_field,
c.some_field
from
parent_table p,
child_table c
where c.fk_field = p.pk_field
If you do want to use a nested select statement, put the sub-query in
your "from" clause, not your "where clause", for instance:
select
p.pk_field,
c.effectivedate
from
(select distinct pk_field from pk_table) p,
child_table c
where c.fk_field = p.pk_field
and c.effectivedate =
(
select max(effectivedate)
from child_table
where fk_field = c.fk_field
)