Subject Re: Inner Joins and 3 tables
Author Alexander V.Nevsky
--- In firebird-support@yahoogroups.com, "Alexander V.Nevsky"
<ded@h...> wrote:
> SELECT a.ASSY_CODE
> FROM MATRIX m
> INNER JOIN MATRIX_CELL_ASSY mca
> ON m.MATRIX_ID = mca.MATRIX_ID
> INNER JOIN ASSEMBLY a
> ON mca.ASSY_ID = a.ASSY_ID WHERE a.ASSY_LIB_ID = mca.ASSY_LIB_ID
> WHERE MATRIX_LIB_ID = 3 And MATRIX_ID = 87

Ooops, did'nt noticed second WHERE. So:

SELECT a.ASSY_CODE
FROM MATRIX m
INNER JOIN MATRIX_CELL_ASSY mca
ON m.MATRIX_ID = mca.MATRIX_ID
INNER JOIN ASSEMBLY a
ON mca.ASSY_ID = a.ASSY_ID
And a.ASSY_LIB_ID = mca.ASSY_LIB_ID
WHERE MATRIX_LIB_ID = 3 And MATRIX_ID = 87

Note I could'nt recognize on which table columns are layed
conditions in WHERE. Optimizer can be confused too and reject to
perform query in dialect 3 database or return wrong result in dialect
1 one. Always specify aliases, I suppose M. for MATRIX in this query
but not sure.

Best regards,
Alexander.