Subject Re: [firebird-support] and again... SQL help needed
Author Yves Glodt
Yves Glodt wrote:

>Hello,
>
>please consider this query:
>
>SELECT
> WT_CORR.EFFECT_DATE,
> WT_CORR.CORR_TYPE,
> WT_CORR.CORR_STATE,
> WT_CORR.CORR_INFO_1,
> WT_CORR.CORR_INFO_2,
> WT_CORR.CORR_INFO_3,
> WT_CORR.TYPE_CORR,
> WT_CORR.CREATOR,
> WT_NOMS.NAME_NAME,
> WT_MOTIFS.REASON_COLOUR,
> WT_MOTIFS.REASON_TYPE
>FROM WT_CORR,WT_NOMS,WT_MOTIFS
> WHERE WT_CORR.IPN=31 AND
> WT_CORR.EFFECT_DATE >= $start AND WT_CORR.EFFECT_DATE <= $end AND
> WT_NOMS.NAME_TYPE=1400 AND
> (WT_CORR.CORR_TYPE = WT_NOMS NAME_NUMBER) AND
> (WT_CORR.CORR_TYPE = WT_NOMS.REASON_NUMBER)
>ORDER BY WT_CORR.EFFECT_DATE
>
>

oops I found a typo... The end shoud read:

(WT_CORR.CORR_TYPE = WT_NOMS NAME_NUMBER) AND
(WT_CORR.CORR_TYPE = WT_MOTIFS.REASON_NUMBER)
ORDER BY WT_CORR.EFFECT_DATE

(I did not prefix every column in my query, just here to give the
context better)

>This is a rough draft, but it works well.
>The 9th column it returns is the textual name of the numeric value from
>column 2. Names are stored in the WT_NOMS table, and in this query are
>linked through the section number "WT_NOMS.NAME_TYPE = 1400"
>
>
>But I need to get another name from the WT_NOMS table, in a section that
>I get in the 10th column, which of course will vary for each returned
>row...
>
>Is there a way to use values returned in a row in a WHERE clause in the
>same query, like "where WT_NOMS.NAME_TYPE=$(value_from_column #10)"
>I was thinkin about a subquery, but I would also need a former result in
>the WHERE.
>
>Is this possible at all with bare sql?
>
>TIA!
>Yves
>
>
>p.s.
>did you know that IBConsole works with wine in Linux? :-)
>The native Linux version only crashes here when I login. :-(
>Does anyone know another native graphical query tool (best would be
>something like winsql) for Linux?
>
>
>