Subject Re: [firebird-support] Re: Select error
Author Svein Erling Tysvaer
OK, then change your query to

select id_aluno, nome_aluno, cod_matr, linhacron_matr, periodoano_matr
from aluno
left join matricula
on idaluno_matr = id_aluno
and periodoano_matr <> '3/2003'
join param_per
on periodoano_paramper = periodoano_matr
and sequencia_paramper = 3

And your plans does not make sense at all. Since nothing is limiting aluno
and it is the left side of a left join, then there is no way it should be
possible to use an index for aluno, i.e. your plan should start with

PLAN JOIN (JOIN (ALUNO INDEX (NATURAL)...

or something similar (I'm uncertain about whether there should be one or
two JOINs in the plan).

HTH,
Set

At 13:03 20.06.2003 +0000, you wrote:
>Hi,
>
>Sorry by my mistake, as a matte of fact the fields
>ending with "_matr" are from table "matricula", as
>the "_aluno" are from table "aluno" and "_paramper"
>are from the table "param_per"
>
>Completing my previous message: if I change the positions
>of "matricula" and "aluno" (between "from" and "join")
>I get the erro on the fourth line fetched.
>
>The IBExpert shows the following plans:
>
>Plan
>PLAN JOIN (JOIN (MATRICULA NATURAL, ALUNO INDEX (RDB$PRIMARY3)),
>PARAM_PER INDEX (RDB$PRIMARY14))
>
>Adapted Plan
>PLAN JOIN (JOIN (MATRICULA NATURAL, ALUNO INDEX (INTEG_8)),
>PARAM_PER INDEX (INTEG_38))
>
>But the Pk of PARAM_PER is periodoano_paramper, which is
>a Char(6)!
>
>Regards.
>
>Luciano RM