Subject Re: [firebird-support] sub select befor from statment
Author Marcin Bury
Piotr

If you don't need check_field in yout result_set
then query will look like that:

select main_table.*
from main_table
where exists (select 1 from second_table where second_table.field =
main_table.field)

HTH
Marcin

piotr.olszewski@... pisze:
> Hi
>
> I have a problem with using as parameter sub selection result
> f.e.:
>
> select main_table.*
> (select first 1 second_table.some_field from second_table where second_table.field = main_table.filed) as check_field
> from main_table
>
> so far is ok, a get records from main_table and check_field from second_table
>
> The problem is when i whant to use this filed in "where statmetn" like:
>
> select main_table.*
> (select first 1 second_table.some_field from second_table where second_table
> field = main_table.filed) as check_field
> from main_table
> where check_field = 1
>
> or when i whant to use check_fild as link to another sub select like:
>
> select main_table.*
> (select first 1 second_table.some_field from second_table where second_table.field = main_table.filed) as check_field
> (select first 1 third_table.some_field from third_table where third.field = check_fild) as check_field2
> from main_table
>
> i know that this kind of solution works on sysbase and it's really make easier to do it.....
>
>
> Please tell mi that this is also posslible with firebird, a have 2.1.1
> version on window xp sp3, and pleas tell mi how to do it....
>
>
> Piotr
>
>
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>