Subject | Re: [firebird-support] left join |
---|---|
Author | Arno Brinkman |
Post date | 2005-03-07T23:15:11Z |
Hi,
The where clause should be in the on clause
SELECT
*
FROM
TABLE1 a
LEFT JOIN TABLE2 a2 ON (a."ID" = a2."ID_ref" and
a2."Val" = :Val and a2."Pos" = :Pos)
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep :
news://80.126.130.81
--
Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.5.2 - Release Date: 28-2-2005
> >have tried to make such query:I think it's late or very early for Helen ;-)
> >
> >select * from TABLE1 a
> >left join ( select * from TABLE2 a2 where a2."Val" = :Val and a2."Pos"
> >= :Pos ) b
> >on a."ID" = b."ID_ref"
> >
> >it seems, that FB1.5 don't support such subqueries (memory tables),
>
> "derived tables" - not until Fb 2 and not using quite your syntax.
>
> >how to rewrite query to get working FB1.5 query?
>
> Well, the derived table seems redundant for this example, which appears to
> be a straightforward left join.
>
> select a.*, a2.*
> from TABLE1 a
> left join TABLE2 a2
> on a."ID" = a2."ID_ref"
> where a2."Val" = :Val
> and a2."Pos" = :Pos
The where clause should be in the on clause
SELECT
*
FROM
TABLE1 a
LEFT JOIN TABLE2 a2 ON (a."ID" = a2."ID_ref" and
a2."Val" = :Val and a2."Pos" = :Pos)
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep :
news://80.126.130.81
--
Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.5.2 - Release Date: 28-2-2005